我使用此代码使用户能够下载 zip 文件:
if(file_exists($filename)){
header("Content-Disposition: attachment; filename=".basename(str_replace(' ', '_', $filename)));
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Description: File Transfer");
header("Content-Length: " . filesize($filename));
flush();
$fp = fopen($filename, "r");
while (!feof($fp))
{
echo fread($fp, 65536);
flush();
}
fclose($fp);
exit;
}
Run Code Online (Sandbox Code Playgroud)
下载文件时,它仅下载 25,632 KB 的数据。但是 zip 文件是 26,252 KB ...
为什么浏览器获得了所有 25MB 然后停止?
我检查了Content-Length标题以确保它是正确的,它是...
在firefox中,当我下载文件时,它说“25mb”所以浏览器认为25mb是完整的数量……但是,echo'd时的内容长度是26252904?
| 归档时间: |
|
| 查看次数: |
5720 次 |
| 最近记录: |