0
我有下面的代碼(從http://www.php.net/manual/en/function.readfile.php)正常投放文件下載:PHP:如何使用ReadFile的與輸出緩衝壓縮
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
但如果我有ob_start('ob_gzhandler');
之前header()
聲明它沒有工作。
不幸的是,這並沒有爲我工作。至少在一臺特定的服務器上,它導致下載在大約80MB後終止。你可能想看看[在相關問題中的這個答案](https://stackoverflow.com/questions/3802510/force-to-open-save-as-popup-open-at-text-link-click -for-pdf-in-html/19416831#19416831),這對我來說效果很好。 – Hendrik