這涉及下載文件用PHPPHP圖片文件下載
我的PHP版本是5.3.5和我的Apache 2.2.17是
我想下載中心文件(PDF,JPG,TIFF)我已經上傳到我的服務器中,並且他們以相同的大小和類型下載,但我看不到它們。我猜他們沒有被複制的權利。但是,當我打開原來上傳的,他們工作得很好。 我已經看到幾乎所有的問題出現建議,他們都沒有回答這個問題,只有類似的是this,但仍然不能回答我的問題。
下載我使用這個代碼
header("Content-type: application/force-download");
header('Content-Disposition: inline; filename="' . $dir . '"');
header("Content-Transfer-Encoding: Binary");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Content-length: ".filesize($dir));
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $file . '"');
readfile("$dir");
其中$dir="62756d616769636e63/646973736572746174/ehddggh/1.JPG"
和$file="1.JPG"
誰能給我一個暗示什麼,我做錯了,或者給我一個更好的解決方案,以下載文件?
'內容type'兩次...'內容disposition'兩次。第一個頭部不會做anythnig(不會被髮送)。'文件大小($ dir)'也有點奇怪,你不覺得嗎? A ** dir **的**文件**大小... – Rudie 2011-04-25 00:33:43