[英]Internet explorer can not download rtf files in PHP application
我一直有 ie8 問題。 它沒有下載我通過腳本上傳到服務器的 rtf 文件。 它正確地保存在數據庫中
我的下載腳本在 php 中
$outname = stripslashes($attachment[0]['dis_attach_content']);
$type = stripslashes($attachment[0]['dis_attach_type']);
$name = stripslashes($attachment[0]['dis_attach_name']);
header("Content-type:" . $type);
header('Content-disposition: attachment; filename=' . $name);
echo($outname);
exit;
這給出了錯誤:
您可以嘗試強制下載:
header("Content-Type: application/force-download");
筆記; 您應該考慮發送更多標頭:
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header('Content-Description: File Transfer');
header("Content-Type: $type");
header('Content-Length: ' . filesize($file));
header('Content-Disposition: attachment; filename=' . basename($file));
將 Content-Disposition 標頭設置為“附件”,就像這樣(在 PHP 中):附件是腳本化的。
header('Content-Disposition: attachment');
並在 .htaccess 中添加以下內容並添加您想要下載的擴展名,而不僅僅是 rtf
<FilesMatch "\.(rtf|txt|pdf|xls|xlsx|xlam|xlsb|xlsm|msg|doc|docx|mpg|jpg|png)">
Header set Content-Disposition attachment
</FilesMatch>
這不太可能是 IE 的問題。
將$name
輸出到瀏覽器,並檢查此 URL 是否准確指向您在服務器上查找的文件。
URL 是否與您的域完全一致? 您可以嘗試使用確切的 URL,例如: http://website.com/file.rtf
: http://website.com/file.rtf
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.