I have an image $file
( eg ../image.jpg
)
which has a mime type $type
How can I output it to the browser?
You can use header to send the right Content-type :
header('Content-Type: ' . $type);
And readfile to output the content of the image :
readfile($file);
And maybe (probably not necessary, but, just in case) you'll have to send the Content-Length header too :
header('Content-Length: ' . filesize($file));
Note : make sure you don't output anything else than your image data (no white space, for instance), or it will no longer be a valid image.