Jump to content

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.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.