I have some images and each image is having a link. When I click on image one popup will open and in that popup I am displaying data in table format. In that table there is a download link. When user click on the download link, file should be download.That was my requirement. Below is my controller function to open popup and display data in table.
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;
}
// Function to download
public function downloadFile($file_name)
{
$this->load->helper('download');
$path = base_url().'upload/files/'.$file_name;
force_download($file_name,$path);
}
But When I click on download link , the download link is going to the browser url like http://localhost/project/mycontroller/downloadFile(filename.doc) like this. Where I am doing wrong? Any help would be greatly appreciated.