ICS file (ICalendar)

0

I'm creating an ics file, which stores dates and data for an event. I want the downloaded file to be in the root where the page is running. And when I load the page, the file is soon downloaded, I wanted it to be when, for example, clicking a link.

<?php

if (isset($_GET['txtstart'])) 
{
    $txtstart = htmlentities($_GET['txtstart']);
}

if (isset($_GET['txtend'])) 
{
    $txtend = htmlentities($_GET['txtend']);
}

if (isset($_GET['txttitle'])) 
{
    $txttitle = htmlentities($_GET['txttitle']);
}

if (isset($_GET['txtdescription'])) 
{
    $txtdescription = htmlentities($_GET['txtdescription']);
}

if (isset($_GET['mois'])) 
{
    $mois = htmlentities($_GET['mois']);
}

if (isset($_GET['annee'])) 
{
    $annee = htmlentities($_GET['annee']);
}
$Filename = "file.ics";
header("Content-Type: text/Calendar"); //ics
header("Content-Disposition: inline; filename=$Filename"); 

$DescDump = str_replace("\r", "=0D=0A=", $txtdescription); 

$dateStart=$annee.$mois.$txtstart."000000";
$vCalStart = date("Ymd\THi00", $dateStart); 

$dateEnd = $annee.$mois.$txtend."000000";
$vCalEnd = date("Ymd\THi00", $dateEnd); ?>

 BEGIN:VCALENDAR 
 VERSION:2.0
 PRODID:SSPCA Web Calendar 
 TZ:-07 
 BEGIN:VEVENT 
 SUMMARY:<?php echo $txttitle ."\n"; ?> 
 DESCRIPTION;ENCODING=QUOTED-PRINTABLE: <?php echo $DescDump ."\n"; ?> 
 DTSTART:<?php echo $vCalStart ."\n"; ?> 
 DTEND:<?php echo $vCalEnd ."\n"; ?> 
 END:VEVENT 
 END:VCALENDAR 

The file is saved in the downloads folder, and you want it to be in the root folder where the page is. And to open the page the file is soon downloaded, I wanted it to be a link or button.

    
asked by anonymous 25.11.2014 / 12:32

1 answer

0

The fact of saving in downloads rather than in root has to do with setting up your browser and not with PHP.

For the download part with link it is easy to just put a reference to this PHP that you put there:

<a href='seuphpacima.php?suasvariaveis=valor'>download</a> 
    
25.11.2014 / 12:47