My ics creator fails when it comes to download the created file. I've tried the following:
function createICS($start, $end, $type, $hrStart, $hrEnd){
$filename = $hrStart."-".$hrEnd." ".$type.".ics";
$string="
BEGIN:VCALENDAR
VERSION:2.0
PRODID:PHP
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:".$start."
DTEND:".$end."
DESCRIPTION:".$type."
SUMMARY:".$type." vom ".$hrStart." bis zum ".$hrEnd."
UID:1
SEQUENCE:0
DTSTAMP:".date('Ymd')."T".date('His')."
END:VEVENT
END:VCALENDAR
";
/*!$handle = fopen($filename, 'W');
fwrite($handle, $string);
fclose($handle)*/
/*header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Length: ". filesize($filename).";");
header("Content-Disposition: attachment; filename=$filename");
header("Content-Type: application/octet-stream; ");
header("Content-Transfer-Encoding: binary");*/
header("Content-Disposition: attachment; filename=\"" . basename($filename) . "\"");
header("Content-Type: application/force-download");
header("Content-Length: " . filesize($filename));
header("Connection: close");
echo $string;
}
But I get just this response instead of the .ics file:
What am I doing wrong? Can someone help me?
Thanks
Yanick