ICS file (Icalendar)

Asked

Viewed 75 times

0

I’m creating an ics file, which stores the dates and data of an event. I want the file when downloading to be at the root where the page is running. And when I load the page, the file is immediately downloaded, I wanted it to be when for example click on 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 stored in the downloads folder, and I wanted it to be in the root folder where the page is. And the opening the page the file is immediately downloaded, I wanted it to be a link or button.

  • And what’s the problem?

  • The file is stored in the downloads folder, and I wanted it to be in the root folder where the page is. And the opening the page the file is immediately downloaded, I wanted it to be a link or Butão.

1 answer

0

The fact of storing in the downloads and not in the root has to do with the configuration of your browser and not with PHP.

For the part of the download with link it’s easy to just put a reference to that PHP you put there:

<a href='seuphpacima.php?suasvariaveis=valor'>download</a> 

Browser other questions tagged

You are not signed in. Login or sign up in order to post.