Home > Backend Development > PHP Tutorial > ie上在excel后内容为空

ie上在excel后内容为空

WBOY
Release: 2016-06-13 12:53:52
Original
834 people have browsed it

ie下在excel后内容为空

<br />
$name = '1.xls';<br />
$file = fopen($name, "rb"); // 打开文件<br />
Header('Content-type: application/octet-stream;charset=utf-8');<br />
//Header("Content-type:application/force-download");<br />
Header('Accept-Ranges:bytes');<br />
Header('Accept-Length:' . filesize($name));<br />
Header('Content-Disposition: attachment; filename="' . $filename.'"');<br />
echo fread($file, filesize($name));<br />
fclose($file);<br />
Copy after login


用火狐和谷歌下载均正常,而用ie下载后的文件内容为空。


------解决方案--------------------
$name = '1.xls';<br />
//$file = fopen($name, "rb"); // 打开文件<br />
Header('Content-type: application/octet-stream;charset=utf-8');<br />
//Header("Content-type:application/force-download");<br />
Header('Accept-Ranges:bytes');<br />
Header('Accept-Length:' . filesize($name));<br />
Header('Content-Disposition: attachment; filename="' . $name.'"');<br />
 readfile($name);<br />
//fclose($file);
Copy after login

这样试试
------解决方案--------------------
那就不知道了。听说360浏览器问题很多。能避开最好别用。

我也没有360浏览器,也不能帮你测试了。
------解决方案--------------------
做好不要用这个方法,你要去下载个PHPExecl插件使用,网站直接可以下载,不受到任何浏览器问题的
http://phpexcel.codeplex.com/下载地址
------解决方案--------------------
认同6楼的提议。 phpexcel确实很强大

引用:
做好不要用这个方法,你要去下载个PHPExecl插件使用,网站直接可以下载,不受到任何浏览器问题的
http://phpexcel.codeplex.com/下载地址

------解决方案--------------------
用file_get_contents函数试试?
Related labels:
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template