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.