• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Invalid or corrupt image when using force download in codeigniter

#1
[eluser]beben[/eluser]
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...

Controller
Code:
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
Code:
function getSuratKeluar(){
    $data = $this->db->get('surat_keluar');
    if ($data->num_rows() > 0){
        foreach ($data->result() as $row){
            $hasil[]=$row;
        }
        return $hasil;
}

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

#2
[eluser]WanWizard[/eluser]
Make sure zlib compression is disabled before you start the download.

#3
[eluser]beben[/eluser]
[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...

#4
[eluser]WanWizard[/eluser]
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.

#5
[eluser]beben[/eluser]
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...


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.