【发布时间】:2015-09-01 04:36:42
【问题描述】:
我想下载我已经上传到我的网站的文件 我只是将文件名保存到数据库中
我的控制器
public function index()
{
$data['file'] = $this->home_model->file();
$this->load->view('file', $data);
}
public function download()
{
$id_file = $this->uri->segment(3);
$data = file_get_contents("/upload/kepsek/".$id_file);
force_download('$id_file', $data);
}
我的模型
function file()
{
$query=$this->db->query("SELECT * FROM silabus");
return $query->result();
}
我的看法
<table class="table table-bordered text-center" id="table-user">
<thead>
<tr class="info">
<th>Download</th>
<th>Pelajaran</th>
</tr>
</thead>
<tbody>
<?php
foreach($file as $data){
?>
<tr>
<td width="50%"><a href="<?php echo site_url('download/download/'.$data->file);?>">Download</a></td>
<td width="50%"><?php echo $data->pelajaran;?></td>
</tr>
<?php
}
?>
</tbody>
<tfoot>
</tfoot>
</table>
当我点击下载时没有发生任何事情 有什么办法让它工作吗?
【问题讨论】:
-
阅读此stackoverflow.com/questions/14835671/… 并尝试使用
_push_file而不是force_download
标签: php codeigniter download helper