I am trying to generate the .ics file through PHP. But after download, the file google chrome showing the dangerous file. The same thing is working fine on my local server. Can anyone let me know how to fix it.?
function dateToCal($time)
{
return date('YmdThis', strtotime($time));
}
// Build the ics file
$ical = 'BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
CALSCALE:GREGORIAN
BEGIN:VEVENT
DTEND:' . dateToCal($_POST['date_end']) . '
UID:' . md5($_POST['summary']) . '
DTSTAMP:' . time() . '
LOCATION:' . addslashes($_POST['location']) . '
DESCRIPTION:' . addslashes($_POST['description']) . '
URL;VALUE=URI: ' . $_POST['url'] . '
SUMMARY:' . addslashes($_POST['summary']) . '
DTSTART:' . dateToCal($_POST['date_start']) . '
END:VEVENT
END:VCALENDAR';
//set correct content-type-header
header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: attachment; filename='.time().'.ics');
echo $ical;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…