$file = "http://www.abax.se/content/download/137/862/file/example.pdf";
header('Content-Description: File Transfer');
header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
flush();
readfile($file);
這是我正在運行的代碼,我出來的想法,任何解決方案?PHP下載給我空PDF
刪除'平齊()'? – Daan 2014-09-26 13:30:39
同樣的東西,空的下載pdf ... – josaric 2014-09-26 13:38:01
這段代碼看起來很奇怪。爲什麼要下載文件才能上傳?你爲什麼不直接發送「301永久移動」響應,將用戶直接發送到文件?該文件是否與此代碼位於同一臺服務器上?如果是這樣,那麼你不應該通過HTTP;您應該直接從服務器讀取並輸出文件。 – 2014-09-26 13:38:08