I use download helper in codeigneter,, when i download file jpeg and open it,, it becomes invalid...
What should i do..
Thank you...
Controller
function downloadSuratElektronik($file)
{
$this->load->helper('download');
$file_data = file_get_contents(base_url()."data/".$file);
$file_name = $file;
force_download($file_name, $file_data);
}
Model
function getSuratKeluar(){
$data = $this->db->get('surat_keluar');
if ($data->num_rows() > 0){
foreach ($data->result() as $row){
$hasil[]=$row;
}
return $hasil;
}
}
View
<table>
<tr>
<td>File Upload</td>
</tr>
<?php
foreach ($hasil as $data) :
?>
<tr>
<td><a href="<?=base_url();?>main/downloadSuratElektronik/<?=$data->link_upload?>">/<?=$data->link_upload?></a></td>
</tr>
<?php endforeach; ?>
</table>