我有在下載文件與笨麻煩..PHP - 笨下載遠程文件
的代碼完全在單獨的PHP文件,但是當我在笨把代碼: 文件將下載成功,但它是損害:(
注:我在工作與視頻文件從遠程服務器
代碼:
$file = fopen ($link, "r");
if (!$file) {
echo "<p align='center' style='color:#FF0101;'>Unable to open remote file :(, Please try again in a few minutes.</p>";
}else{
ob_clean();
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header('Content-Disposition: attachment; filename=zxc.3gp');
//header("Content-Transfer-Encoding: binary");
//header("Content-Length: ".$video_size);
while (!feof ($file)) {
$line = fgets ($file, 1024);
echo $line;
ob_flush();
flush();
}
fclose($file);
die();
}
我嘗試這種代碼在新項目的CodeIgniter:
public function index()
{
$link = 'http://mamprogr.net.tc/tmp/1.3gp';
$this->load->helper('download');
force_download('1.3gp',$link);
}
但不工作:(
問題是什麼?什麼不工作?任何錯誤消息? [你有什麼嘗試?](http://www.whathaveyoutried.com) – orourkek 2012-08-07 16:20:24
CodeIgniter [輸出類](http://codeigniter.com/user_guide/libraries/output.html)的責備!參見< - 該頁面。 我不知道如何解決問題,但這是問題所在。 – Prasanth 2012-08-07 16:54:19
你用gzip壓縮輸出嗎?如果是這樣,那是你的問題。如果啓用gzip壓縮,則無法直接從控制器方法輸出內容。你必須使用一個視圖。 – Brendan 2012-08-07 17:08:15