Jump to content

creating ics files on the fly


predator

Recommended Posts

Hi i have the following code which is not prompting to download automatically can anyone help me so the save dialogue box auto pops up so you can save it as the correct file type please.

thanks

Mark

<?
//header('Content-Type: application/octet-stream');
header("Content-Type: text/Calendar");
    header("Content-disposition: inline; filename=foobar.ics");

// then here's all your output for the file
?>
BEGIN:vCalendar<br />
VERSION:2.0<br />
METHOD:PUBLISH<br />
BEGIN:vEvent<br />
DTSTART:20080112T190000Z <? /*DATE AND TIME EVENT STARTS  20080112T190000Z  */?><br />
DTEND:20080112T190000Z <? /*DATE AND TIME EVENT ENDS  20080112T190000Z  */?><br />
UID:1032356281<br />
DTSTAMP:20081223T190000Z <? //THIS IS CURRENT DATE?><br />
DESCRIPTION: MESSAGE SHOWN HERE US \N TO DO A BREAK LINE<br />
SUMMARY: THIS IS THE TITLE PAGE<br />
PRIORITY:3<br />
BEGIN:vAlarm<br />
TRIGGER:P0DT0H15M<br />
ACTION:DISPLAY<br />
DESCRIPTION:Reminder<br />
END:vAlarm<br />
END:vEvent<br />
END:vCalendar<br />

 

Link to comment
https://forums.phpfreaks.com/topic/82990-creating-ics-files-on-the-fly/
Share on other sites

Here's the code I use

 

header('Content-Type: text/csv; name="' . $filename );
                switch ($disposition) {
                case 'attachment':
                        header('Content-Disposition: attachment; filename="' . $filename . '"');
                        break;
                case 'inline':
                default:
                        header('Content-Disposition: inline; filename="' . $filename . '"');
                        break;
                }

 

Inline will attempt to display in the browser, attachment will attempt to prompt for download.  What actually happens will depend on the browser.  Remember to quote the filename.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.