IE6下php header實現檔案下載錯誤_PHP教程

來源:互聯網
上載者:User
使用php header實現檔案下載時,在IE6下總是提示不能下載,Google瀏覽器正常, 因此應該是IE的問題,IE下有個bug,微軟官網有說明。錯誤訊息:“Internet Explorer cannot download a file”(Internet Explorer 不能下載檔案),有個辦法可以很好的解決,

看代碼好了:

下面整理了一個函數

代碼如下 複製代碼

if(strstr($_SERVER["HTTP_USER_AGENT"],"MSIE")==false) {
header("Cache-Control: no-cache");
header("Pragma: no-cache");
}

header('Cache-Control: public, must-revalidate, max-age=0');
header('Accept-Ranges: bytes');
header("Content-Type: application/force-download");
header("Content-Type: application/download");
header("Content-Type: application/octet-stream");
if(!empty($content_type)){
header("Content-Type: ".$content_type);
}
header("Content-Transfer-Encoding: binary");
header('Content-Disposition:attachment;filename="'.rawurlencode($filename).'"');

http://www.bkjia.com/PHPjc/632115.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/632115.htmlTechArticle使用php header實現檔案下載時,在IE6下總是提示不能下載,Google瀏覽器正常, 因此應該是IE的問題,IE下有個bug,微軟官網有說明。錯誤訊息...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.