作者angelmark (湖畔風晴)
看板PHP
標題[請益] header download file變成PHP
時間Fri May 13 16:53:59 2011
各位大大
小弟不才 想請問
我現在有個頁面叫做download.php
程式碼如下
$file_name = "test.rar";
$file_path = "download/test.rar";
$file_size = filesize($file_path);
header('Pragma: publlic');
header('Expires:0');
header('Last-Modified: ' . gmdate('D, d M Y H:i ') . ' GMT');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false);
//header('Content-Type: application/octet-stream');
header('Content-Type: application/x-rar-compressed');
header('Content-Length: ' . $file_size);
header('Content-Disposition: attachment; filename="' . $file_name . '";');
header('Content-Transfer-Encoding: binary');
readfile($file_path);
----------------------------------分行線---------------------------------
首先 我的檔案大小約1.XXG
我點選網頁下載檔案時
我連結不到我的download.php頁面
找不到檔案
http://xxx.xxx.xxx/download.php
當我將檔案換成另一個的時候
檔案大小大約為5XM
此時
找的到了
但是下載的檔案變成了download.php
而不是我所指定的test.rar
不知道為什麼會這樣
是因為下載檔案容量的問題嗎?
我被這個問題困擾好久了
希望各位大大能夠幫助我
剛剛把
header('Content-Type: application/x-rar-compressed');
變成
header('Content-Type: application/force-download');
可以成功的下載5Xm的檔案了
但是1.xxG的檔案還是找不到網頁
是因為檔案大小的問題嗎?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 219.81.19.118
※ 編輯: angelmark 來自: 219.81.19.118 (05/13 17:00)
→ lance70176:不是檔案大小問題 05/13 17:53
→ angelmark:那是什麼問題呢~"~很困擾 05/13 18:30
推 chief84:application/x-rar 05/14 00:34
→ chief84:file size 不指定好像沒關係 05/14 00:36
→ angelmark:我改成x-rar還是不行內~"~ 05/14 14:20
→ mattttt:PHP能用記憶體很小喔,加大使用記憶體看看 05/14 19:24