[英]File Download using PHP/Apache2 and Google Chrome
The download method I am using: 我正在使用的下载方法:
window.open
with the proper url and attached file name to start the download. window.open
并带有正确的URL和附加文件名以开始下载。 However the download fails on Google Chrome 45.0.2454.85 m on Windows 7. It just opens a new blank window and then nothing happens. 但是,在Windows 7上的Google Chrome 45.0.2454.85 m上下载失败 。它只是打开一个新的空白窗口,然后什么也没有发生。 I have browser cache cleared.
我已清除浏览器缓存。 What is the right way to start a file download for Chrome?
什么是开始下载Chrome文件的正确方法?
Here is the PHP code responsible for the download. 这是负责下载的PHP代码。
header("Content-Description: File Transfer");
header("Content-Type: text/csv");
header("Content-Disposition: attachment; filename=". basename($filename));
header("Expires: 0");
header("Cache-Control: must-revalidate");
header("Pragma: public");
header("Content-Length: ". filesize($filename));
ob_clean();
flush();
readFile($filename);
Try write all your headers after ob_clean(). 尝试在ob_clean()之后写入所有标头。 ob_clean() clear all data with headers.
ob_clean()清除所有带有标题的数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.