簡體   English   中英

PHP文件下載字節丟失

[英]PHP file downloads bytes missing

我正在嘗試下載一個.msi文件,它的實際大小是5.77 MB。 當我執行腳本時,下載的文件將丟失一些字節,將變為4.88 MB。

碼:

$file = 'apps/file.msi';
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 5');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);

我什至嘗試使用錨標記,也發生了同樣的情況。 我還將擴展名從.msi更改為.txt ,並且字節也從下載的文件中刪除。

我只是想不通

嘗試這個

$file = 'apps/file.msi';
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary"); 
header("Content-disposition: attachment; filename=\"" . basename($file) . "\""); 
readfile($file); 

也許您的服務器配置為gzip傳輸的內容

http://en.wikipedia.org/wiki/HTTP_compression

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM