Welcome Guest, Not a member yet? Register   Sign In
force download issue
#1

[eluser]dorwin[/eluser]
Hello,

I have a little problem with force download helper, the download is OK, files size are the same but the file is unreadable,

See for example download link here : http://www.wow-ui.com/fr/media/view/1/first.html (on the right "Telecharger")

it is this file : http://www.wow-ui.com/medias/img1143446772.jpg

As you see, both 426kb but downloaded file can't be open by windows :/

There is my code :
Code:
function download()
    {
        $file = $_SERVER['HTTP_REFERER'];
        $file = explode('/', $file);
        $id_image = $file[6];
        if (is_numeric($id_image))
            $image = $this->medias->get_image($id_image);
        $this->load->helper('download');
        $data = file_get_contents(base_url()."medias/".$image->nom.".jpg");
        $name = $image->nom.'.jpg';
        force_download($name, $data);    
    }

Any suggestion ? Maybe a problem of encode ?

Thanks !
#2

[eluser]LuckyFella73[/eluser]
Hi Dorwin,

I downloaded the file and was able to open it with acdsee. The windows
image viewer fails .. Maybe you try to sae the image with an other
image sofware or check if you can adjust some settings while saving.
#3

[eluser]JoostV[/eluser]
I could open it with irfan view, no problem.
Have you tried setting the mime type manually in http://www.wow-ui.com/fr/media/download.html?
Code:
header('Content-Type: image/jpeg');
#4

[eluser]dorwin[/eluser]
It is really weird, I compared the files and the only diference is 3 tabulation on the file downladed with helper...

I tryed some different header but I give up and use this function found on the web :
Code:
$file = 'medias/'.$image->nom.'.jpg';
    
            if (file_exists($file))
            {
                header('Content-Description: File Transfer');
                header('Content-Type: application/octet-stream');
                header('Content-Disposition: attachment; filename='.basename($file));
                header('Content-Transfer-Encoding: binary');
                header('Expires: 0');
                header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
                header('Pragma: public');
                header('Content-Length: ' . filesize($file));
                ob_clean();
                flush();
                readfile($file);
                exit;
            }
Well, thanks for answer !
#5

[eluser]veledrom[/eluser]
Having the same problem with dorwin, I solved the problem with dorwins solution since no one knows why CI cannot help us with this issue.




Theme © iAndrew 2016 - Forum software by © MyBB