我在PHP中编写了一个下载脚本,如下所示,我的脚本正在正确下载文件,但我觉得浏览器(chrome)进度条没有定期更新。
我的文件大小为320MB,在下载该文件时,进度随机更新为“11MB,76MB,200Mb& 320MB”或“70MB& 320MB”等。
在大多数网站中,下载进度更新发生在每个MB之后的常量块中,因此我想知道如何控制进度更新间隔,可能是通过发送一些额外的标头或其他内容。
我想通过以固定间隔更新进度来改善用户体验,所以任何人都可以帮我正确处理这种情况。
// HTTP Headers for ZIP File Downloads // http://perishablepress.com/press/2010/11/17/http-headers-file-downloads/ // file variables $filename = "Movie Tunes.zip"; $filepath = "files/"; // http headers for zip downloads header("Pragma: public"); header("Expires: 0"); header("Cache-Control: public,must-revalidate, post-check=0, pre-check=0"); header("Content-Description: File Transfer"); // MIME header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"".$filename."\""); header("Content-Transfer-Encoding: binary"); // MIME header("Content-Length: ".filesize($filepath.$filename)); ob_end_flush(); @readfile($filepath.$filename);
谢谢,
希瓦
答案 0 :(得分:0)
不,您无法影响浏览器何时/如何更新其下载进度条。