karldesign Posted March 12, 2008 Share Posted March 12, 2008 Trying to find an answer for this, so hope you can all help... I have an events calendar on a website that I would like users to be able to download an iCal/Outlook calendar reminder. I have created the file by using php: $fileid = $_GET['id']; $filename = $fileid.".ics"; $fileopen = fopen($filename, 'w') or die("can't open file"); $filecontent = "BEGIN:VCALENDAR VERSION:2.0 METHOD:PUBLISH BEGIN:VEVENT ORGANIZER: DTSTART;VALUE=DATE:$starts DTEND;VALUE=DATE:$ends LOCATION:location URL:url TRANSP:TRANSPARENT SEQUENCE:0 UID:111 DTSTAMP:20080117T102312Z DESCRIPTION:test SUMMARY:test PRIORITY:5 X-MICROSOFT-CDO-IMPORTANCE:1 CLASS:PUBLIC END:VEVENT END:VCALENDAR"; fwrite($fileopen, $filecontent); fclose($fileopen); The problem is, when a user downloads this file, it only shows in the browser (text) and does not attempt to download the .ics file... Any help would be great! Link to comment https://forums.phpfreaks.com/topic/95837-ical-outlook/ Share on other sites More sharing options...
soycharliente Posted March 12, 2008 Share Posted March 12, 2008 You could use Javascript to open a new window, force a save, then close the new window. I've done that before. I'm sure SOMEONE will rant and rave about that, but it's A solution. Link to comment https://forums.phpfreaks.com/topic/95837-ical-outlook/#findComment-490604 Share on other sites More sharing options...
karldesign Posted March 12, 2008 Author Share Posted March 12, 2008 would rather not use javascript were possible... Link to comment https://forums.phpfreaks.com/topic/95837-ical-outlook/#findComment-490615 Share on other sites More sharing options...
haku Posted March 12, 2008 Share Posted March 12, 2008 Google "php force download". There are a number of scripts out there that can do this for you. Link to comment https://forums.phpfreaks.com/topic/95837-ical-outlook/#findComment-490619 Share on other sites More sharing options...
karldesign Posted March 12, 2008 Author Share Posted March 12, 2008 Yeh, tried this, but unfortunately, I cannot send any headers... Link to comment https://forums.phpfreaks.com/topic/95837-ical-outlook/#findComment-490631 Share on other sites More sharing options...
haku Posted March 12, 2008 Share Posted March 12, 2008 Why can't you send headers? If you can't send headers, then you wont be able to force a download. You will need to require the user to open the file then to save it as the required file type manually. Link to comment https://forums.phpfreaks.com/topic/95837-ical-outlook/#findComment-490637 Share on other sites More sharing options...
karldesign Posted March 12, 2008 Author Share Posted March 12, 2008 i get the 'headers already sent' error when i try using them again... Link to comment https://forums.phpfreaks.com/topic/95837-ical-outlook/#findComment-490643 Share on other sites More sharing options...
haku Posted March 12, 2008 Share Posted March 12, 2008 Then the problem isn't that you cant send headers, the problem is that you put your code together wrongly. Link to comment https://forums.phpfreaks.com/topic/95837-ical-outlook/#findComment-490651 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.