PHP IE中下载附件问题解决方法
重点:
1、在IE中下载附件之前要清空缓存。
2、中文文件名要用urlencode编码。
或
1、在IE中下载附件之前要清空缓存。
2、中文文件名要用urlencode编码。
代码如下:
Header("Pragma: "); //不加的话,IE中会提示目标主机无法访问 Header("Cache-Control: "); //不加的话,IE中会提示目标主机无法访问 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中文名会出现乱码 readfile($path_c); exit;
或
代码如下:
header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.urlencode(basename($file) )); //IE中不用urlencode中文名会出现乱码 header('Content-Transfer-Encoding: binary'); //二进制传输 header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); //不加的话,IE中会提示目标主机无法访问 header('Pragma: public'); //不加的话,IE中会提示目标主机无法访问 header('Content-Length: ' . filesize($file)); ob_clean(); flush(); readfile($file); exit;
相关推荐
kentrl 2020-11-10
咻咻ing 2020-07-04
wghou 2020-06-16
zkwgpp 2020-06-14
xiechao000 2020-05-18
woniyu 2020-05-14
ysmh00 2020-05-14
0与的世界 2020-04-28
worldkun 2020-05-10
carolAnn 2020-04-20
zengni 2020-02-29
hygbuaa 2020-02-26
zhaolisha 2020-02-24
server { listen 80; server_name ××××.com; access_log /×××/×××/nginx/log/access.log; error_log /×××/×
咻咻ing 2020-02-02
JF0 2020-01-31
OwenJi 2020-01-17
webfullStack 2020-01-10