I have an image $file ( eg ../image.jpg )
which has a mime type $type
How can I output it to the browser?
header("Content-type: image/png");
echo file_get_contents(".../image.png");
The first step is retrieve the image from a particular location and then store it on to a variable for that purpose we use the function file_get_contents() with the destination as the parameter. Next we set the content type of the output page as image type using the header file. Finally we print the retrieved file using echo.