看來我成功地創建一個對即時ZIP檔案(文件大小和file_exists都返回預期值),但是當我嘗試實際下載它,我收到一個空的ZIP文件。奇怪的是,這個錯誤同時發生在readfile和fread上。這是我的代碼PHP的飛行ZIP下載空白
$filename = $zip;
$handle = fopen($filename, 'r');
if ($handle === false)
{
die('Could not read file "' . $filename . '"');
}
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="fsdownload.zip"');
header('Cache-Control: private');
while (!feof($handle))
{
echo fread($handle, 8192);
}
fclose($handle);
這適用於zip文件< 10 MB。任何想法可能是什麼問題?
是什麼PHP錯誤日誌不得不說一下嗎? – Nameless
給fpassthru一個去。還需要多長時間才能下載? – Sam