我有在下载文件与笨麻烦..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