這篇文章主要介紹“如何解決PHP IE中下載附件問題”,在日常操作中,相信很多人在如何解決PHP IE中下載附件問題問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”如何解決PHP IE中下載附件問題”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!
重點:
1、在IE中下載附件之前要清空緩存。
2、中文文件名要用urlencode編碼。
復(fù)制代碼 代碼如下:
Header("Pragma: "); //不加的話,IE中會提示目標(biāo)主機無法訪問
Header("Cache-Control: "); //不加的話,IE中會提示目標(biāo)主機無法訪問
Header("content-type: $type");
Header("accept-ranges: bytes");
Header("Content-Transfer-Encoding:base64");
Header("accept-length: " . filesize($path_c));
Header("content-disposition: attachment; filename=" .urlencode($filename)); //IE中不用urlencode中文名會出現(xiàn)亂碼
readfile($path_c);
exit;
或
復(fù)制代碼 代碼如下:
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.urlencode(basename($file) )); //IE中不用urlencode中文名會出現(xiàn)亂碼
header('Content-Transfer-Encoding: binary'); //二進制傳輸
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); //不加的話,IE中會提示目標(biāo)主機無法訪問
header('Pragma: public'); //不加的話,IE中會提示目標(biāo)主機無法訪問
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
到此,關(guān)于“如何解決PHP IE中下載附件問題”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>
當(dāng)前標(biāo)題:如何解決PHPIE中下載附件問題-創(chuàng)新互聯(lián)
網(wǎng)頁網(wǎng)址:http://www.rwnh.cn/article24/jdoje.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站設(shè)計、微信公眾號、微信小程序、自適應(yīng)網(wǎng)站、網(wǎng)頁設(shè)計公司、搜索引擎優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容