作者gyd (ipod touch之路)
看板PHP
標題Re: [請益] 請問關於壓縮檔下載 抓完後確無法解壓縮
時間Thu Apr 30 01:17:22 2009
※ 引述《gyd (ipod touch之路)》之銘言:
: 先提供一下出問題的網址
: http://mail.csie.ncyu.edu.tw/~s0914707/SanguoMusou4.php
: 我很確定該資料檔是對的,我比對大小發現大小都是對的,但是卻是壞的
: 使用winrar內建的壓縮檔修復工具則可以成功修復
: 訊息是說標頭損壞
: 想請問是那邊有問題
: 以下為download.php的內容,Button只作連結的工作
: <?php
: ob_start();
: $file_name = $_GET[file];
: $file_url = rawurlencode($file_name);
: header('Content-Description: File Transfer');
: header('Content-Type: application/octet-stream');
: header("Content-Disposition: attachment; filename=$file_name");
: header('Content-Transfer-Encoding: binary');
: header('Expires: 0');
: header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
: header('Pragma: public');
: header('Content-Length: ' . filesize($file_name));
: ob_clean();
: flush();
: readfile($file_url);
: ?>
: 順便再問一下,如何隱藏滑鼠移上Button時,在瀏覽器最左下會顯示的連結位置
自問自答
ob_start()拿掉即可
另外,是否有人可以清楚的解釋以下2個function
ob_clean()
flush()
因為我在download.php中呼叫時,download.php?file=XXX.rar
只要有傳入參數,就得要用ob_start()去作緩衝
但是我發現用ob_clean();flush()這個方式去做卻不會造成這樣的bug
更誇張的是連ob_start都不用加了
有大師可以解惑?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.127.240.89
推 fillmore :1. 我覺得你應該先照LPH66說的先比對原始檔案 04/30 02:46
→ fillmore :2. 只是下載檔案直接導向真實載點不是更快嗎? 04/30 02:47
→ gyd :fillmore哥是否沒有看文章全文,我已經提到解決方式了 04/30 13:17
推 fillmore :當然有看過- -你要不要試一下看看下載個100MB檔案? 04/30 20:55
→ gyd :有試過,不過我已經知道問題點,文中有說了 05/01 07:54
→ gyd :所以我現在想知道的是發生原因,謝謝回應 05/01 07:55