我在下载文件时遇到了 CodeIgniter 的问题。
该代码在单独的 php 文件中完美运行,但是当我将代码放入 CodeIgniter 时:该文件将成功下载,但已损坏:(。
注意:我正在处理来自远程服务器的视频文件。
编码:
$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);
}
但不工作:(