Welcome Guest, Not a member yet? Register   Sign In
Problems with read_file and seeing two requests
#1

[eluser]louis w[/eluser]
I am trying to use readfile (or CI read_file) to load an image from the server and output it to the browser. What is really strange is that if I watch my logs I see two requests happening right after each other every time it runs.

This is what I am running:

// Shows the image, but two requests show up in system logs
header('Content-type: '.$file['mime']);
readfile($load_path);

// Outputs binary data to browser
$this->output->set_header('Content-type: '.$file['mime']);
readfile($load_path);

// Doesn't work
$this->output->set_header('Content-type: '.$file['mime']);
return read_file($load_path);

Any idea what might be going on?
#2

[eluser]eger[/eluser]
I am running into the same issue trying to use set_header to set image/png content type and readfile to output the png data. It just outputs binary data and it doesn't seem that the proper headers are sent. Did you ever resolve your issue?
#3

[eluser]louis w[/eluser]
If I recall, the solution I settled upon was to just do normal php function and to not use the built in CI ones. This is what I am using and it appears to be working since I forgot I even posted this Smile Hope it helps.

Code:
header('Content-type: '.$file['mime']);
readfile($file['load_path']);
#4

[eluser]eger[/eluser]
Gotcha, that was what I was going to try next. Though it would be nice to know if the CI function is not working properly or if we were doing something wrong..




Theme © iAndrew 2016 - Forum software by © MyBB