Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

force_download problems when generating image #1782

Closed
rodrigoalex opened this Issue · 10 comments

5 participants

@rodrigoalex

When trying to force a download of an image, the image is not generated correctly generate a corrupted image

@appleboy

Please show your source code.

@mincms1

are you all use CI 3.0 ?

@narfbg
Owner

There's nothing to be generated for an already existing file.

@rodrigoalex

Hi guys, answers:

1- I am using CI 2.1.2
2- my code:

$this->load->helper('download');
force_download($name_file, file_get_contents('./docs/'.$data->row()->folder.'/'.$file));

When the file is PDF or Word, works perfectly, because I created a controller and do everything dynamically.

Gives no error, just does not generate the image correctly

Thanks guys,

Rodrigo

@alexbilbie

What is the MIME type of the download?

@rodrigoalex

jpeg or jpg both returned with errors

@alexbilbie

Sorry I mean is the server outputting the file with image/jpg or application/octet-stream or maybe something else?

@rodrigoalex

I do not know for sure. Clicking on the download link that leads to the controller, the image appears to save or open (normal so far), but try to save and open the image is returned the message: "Window can not open file" and is not generated no preview thumbnail image.

Controller:

class download extends CI_Controller {
    public function index($file) {
        if(login()) {
            $this->load->model('docs/all_docs');
            $data = $this->all_docs->files(array('name' => $file));

            $this->load->helper('download');
            force_download($file, file_get_contents('./docs/'.$data->row()->folder.'/'.$file));             
        }
    }
}

Line returns no error, no warning, just does not generate the image correctly.

Thanks,

Rodrigo

@narfbg
Owner

Which browser do you use? Have you tried with another one?

@narfbg
Owner

This new feature should help: 53fff91

@narfbg narfbg closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.