【发布时间】:2015-10-19 17:41:13
【问题描述】:
$data = 'Here is some text!';
$name = 'mytext.txt';
force_download($name, $data);
这是我需要从数据库或我的保存路径文件夹下载的简单 bownload 代码位。
我需要 MVC codeigniter 框架中的完整代码。
我在数据库和给定路径文件夹中上传文件保存文件夹。
此代码无法正常工作,请向我发送带有模型视图控制器的完整代码。
function download($fid){
$query= $this->db->get_where('files',array('fid' => $fid));
$row = $query->result();
header("Content-Type: ". $row[0]->type);
header("Content-Length: ". $row[0]->size);
header("Content-Disposition: attachment; filename=". $row[0]->name);
// Print data
echo $row[0]->content;
//Free the mysql resources
mysql_free_result($result);
//redirect('index.php/files/search/'.$fid);
}
【问题讨论】:
标签: codeigniter