Welcome Guest, Not a member yet? Register   Sign In
Invalid or corrupt image when using force download in codeigniter

I use download helper in codeigneter,, when i download file jpeg and open it,, it becomes invalid or corrupt...

What should i do..

Thank you...

function downloadSuratElektronik($file)
    $file_data = file_get_contents(base_url()."data/".$file);
    $file_name = $file;
    force_download($file_name, $file_data);

function getSuratKeluar(){
    $data = $this->db->get('surat_keluar');
    if ($data->num_rows() > 0){
        foreach ($data->result() as $row){
        return $hasil;

    <td>File Upload</td>
    foreach ($hasil as $data) :
    <td><a href="&lt;?=base_url();?&gt;main/downloadSuratElektronik/&lt;?=$data-&gt;link_upload?&gt;">
    &lt;?php endforeach; ?&gt;

Make sure zlib compression is disabled before you start the download.

[quote author="WanWizard" date="1338892443"]Make sure zlib compression is disabled before you start the download.[/quote]

What do you mean with zlib compression ?? sorry,, i'm still the newbie... thank you for your help...

If you have enabled output compression, either in the CI config or in your php.ini, you need to disable it, as it will alter the data sent to the client.

i have disabled output compression in php.ini,, but nothing change...

but,, in ci config ?? how to setting it ?? i don't understand how to disabled output compression in ci.. thank you...

Theme © iAndrew 2016 - Forum software by © MyBB