Home > php教程 > php手册 > IE6下php header实现文件下载错误

IE6下php header实现文件下载错误

WBOY
Release: 2016-06-13 09:56:57
Original
830 people have browsed it

使用php header实现文件下载时,在IE6下总是提示不能下载,谷歌浏览器正常, 因此应该是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).'"');

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template