I have got an SQLite3 Database with several images in it. I want to display these Images in a Browser (Images are fetched from DB via PHP Script).
header('Content-type: image/jpeg');
$img=$this->getImgData($mid);
//next line is just for testing purposes
file_put_contents("/tmp/thumb.jpg", $img);
echo $img;
exit();
The Problem is:
The Image /tmp/thumb.jpg can be viewed by any image Viewer, but the browser calling this php script (which gets the exact same data as in /tmp/thumb.jpg) refuses to display it.
How could that be?
Found the Problem:
I copied the content type from a webpage to my IDE.
It seems like the “space” between “Content-type:” and “image/jpeg” wasn’t a space but rather any other invisible unicode char. So i just keyed in the header by hand – and it worked!