重点:
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;
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;
标签:
PHP,IE,下载附件
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com
暂无“PHP IE中下载附件问题解决方法”评论...