【发布时间】:2011-07-26 23:54:00
【问题描述】:
我用这个代码下载文件
$file='test.mp3'; $download_rate = 50; //50 kb/s if(file_exists($file) && is_file($file)) { header('缓存控制:私有'); header('Content-Type: application/octet-stream'); header('内容长度:'.filesize($file)); header('Content-Disposition: filename='.$file); 冲洗(); $file = fopen($file, "r"); 而(!feof($文件)) { // 将当前文件部分发送到浏览器 打印 fread($file, round($download_rate * 1024)); // 刷新内容到浏览器 冲洗(); // 休眠一秒 睡眠(1); } fclose($文件); } 别的 { echo '找不到文件'; }但在下载文件时无法浏览网站,直到下载完成。这发生在 IE 和 Firefox 上
有答案吗?
【问题讨论】:
-
不确定但不要调用flush();定义标题后,您只需在输出文件数据时调用它。
-
这个问题的正确答案是什么?
标签: php download while-loop