我有一些图像,每个图像都有一个链接。当我单击图像时,将打开一个弹出窗口,在该弹出窗口中,我以表格格式显示数据。该表中有一个下载链接。当用户单击下载链接时,应该下载文件。这是我的要求。下面是我的控制器功能,用于打开弹出窗口并在表格中显示数据。
public function viewCommunication()
{
$post_data = $this->input->post();
$c_id = $post_data['c_id'];
$m_id = $post_data['m_id'];
$this->db->where("(c_id IN($c_id) AND mentee_id IN ($m_id))");
$query = $this->db->get('upload_checklist');
$checklist_data = $query->result();
$data['viewchecklist_data'] = json_decode(json_encode($checklist_data),TRUE);
$data4 = "";
$data4.='<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Initial Meeting</th>
</tr>
</thead>
<tbody>';
foreach($data['viewchecklist_data'] as $key=>$value){
$download_link = 'MyController/downloadFile($value['initial_meeting'])';
$data4.='<tr>
<td><a href='.$download_link.'>'.$initial_meeting.'</a></td>
</tr>';
}
$data4.='</tbody> </table>';
echo $data4;
}
//下载功能
public function downloadFile($file_name)
{
$this->load->helper('download');
$path = base_url().'upload/files/'.$file_name;
force_download($file_name,$path);
}
但是,当我单击下载链接时,下载链接将转到http://localhost/project/mycontroller/downloadFile(filename.doc)这样的浏览器网址。我在哪里做错了?任何帮助将不胜感激。