[英]Can't download generated .ics-file in Chrome or Firefox
I've generated a ics-file via my php script which allows me to download a .ics-file in Safari (6.0.2) but in Chrome (23.0.1271.101) and Firefox (17.0.1) I get an error message: 我通过我的php脚本生成了一个ics文件,它允许我在Safari(6.0.2)中下载.ics文件但在Chrome(23.0.1271.101)和Firefox(17.0.1)中我收到一条错误消息:
Error 6 (net::ERR_FILE_NOT_FOUND): The file or directory could not be found.
错误6(net :: ERR_FILE_NOT_FOUND):找不到文件或目录。
The .ics-file is valid (checked with two separate sources) and I can open it in iCal. .ics文件有效(使用两个单独的源进行检查),我可以在iCal中打开它。 I've followed scripts and tips on both this forum and many others.
我在这个论坛和其他许多论坛上都遵循了脚本和提示。
This is the code that generates the .ics-file: 这是生成.ics文件的代码:
$tz_sthlm = new DateTimeZone( 'Europe/Stockholm' );
$tz_utc = new DateTimeZone('UTC');
$dateEvent = new DateTime( $event->datetime, $tz_sthlm );
$dateEvent->setTimezone( $tz_utc );
$filename = str_replace('/', '-', $event->webblink);
$output = '';
$output .= 'BEGIN:VCALENDAR' . "\r\n";
$output .= 'VERSION:2.0' . "\r\n";
$output .= 'PRODID:-//Medicinska Foreningen Orebro//Biljettbokning//SV-SE' . "\r\n";
$output .= 'METHOD:PUBLISH' . "\r\n";
$output .= 'BEGIN:VEVENT' . "\r\n";
$output .= 'CLASS:PUBLIC' . "\r\n";
$output .= 'CREATED:' . date('Ymd\THis') . "\r\n";
$description = strip_tags( htmlspecialchars_decode( $event->description ) );
$description = str_replace(array( "\n", ';' ), array( '\n', '\;' ), $description);
$output .= 'DESCRIPTION:' . $description . "\r\n";
$output .= 'DTSTART:' . $dateEvent->format('Ymd\THis\Z') . "\r\n";
$dateEvent->modify('+4 hour');
$output .= 'DTEND:' . $dateEvent->format( 'Ymd\THis\Z' ) . "\r\n";
$output .= 'DTSTAMP:' . $dateEvent->format('Ymd\THis\Z') . "\r\n";
$output .= 'LAST-MODIFIED:' . date('Ymd\THis') . "\r\n";
$output .= 'LOCATION:' . $event->location . "\r\n";
$output .= 'UID:' . $dateEvent->format('Ymd\THis') . '-' . md5( $event->title ) . '@' . $_SERVER['SERVER_NAME'] . "\r\n";
$output .= 'END:VEVENT' . "\r\n";
$output .= 'END:VCALENDAR';
header("Content-Type: text/Calendar;charset=utf-8");
header('Content-Disposition: inline; filename="' . $filename . '.ics"');
/* header('Content-Transfer-Encoding: binary');
header('Expires: -1');
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header('Pragma: public');
header('Content-Length: ' . mb_strlen( $output, '8bit' ) );
*/
echo $output;
exit;
This is the output 这是输出
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//My Company//SV-SE
METHOD:PUBLISH
BEGIN:VEVENT
CLASS:PUBLIC
CREATED:20130105T000547
DESCRIPTION:This is my description.
DTSTART:20130124T170000Z
DTEND:20130124T210000Z
DTSTAMP:20130124T210000Z
LAST-MODIFIED:20130105T000547
LOCATION:Top secret
UID:20130124T210000-c88f2fb3f033284ec886aa15acb9eaee@example.com
END:VEVENT
END:VCALENDAR
Any ideas to why I get and error message in Chrome and Firefox? 我在Chrome和Firefox中获得的原因和错误消息的任何想法?
Many thanks in advance 提前谢谢了
由于文件正在发送404标头状态,请尝试放置此标头:
header('HTTP/1.0 200 OK', true, 200);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.