predator Posted December 24, 2007 Share Posted December 24, 2007 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 More sharing options...
btherl Posted December 24, 2007 Share Posted December 24, 2007 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. Link to comment https://forums.phpfreaks.com/topic/82990-creating-ics-files-on-the-fly/#findComment-422185 Share on other sites More sharing options...
predator Posted December 24, 2007 Author Share Posted December 24, 2007 thanks very much mate the worked a treat. Regards Mark Link to comment https://forums.phpfreaks.com/topic/82990-creating-ics-files-on-the-fly/#findComment-422335 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.