I have an image $file
( eg ../image.jpg
)
which has a mime type $type
How can I output it to the browser?
Store the image in a variable such that, Echo the image from the variable without changing headers. You can do this in two ways. In way one, you serialize the image in a string, and save the string in the session.
PNG is short for Portable Network Graphic, a type of raster image file. It's particularly popular file type with web designers because it can handle graphics with transparent or semi-transparent backgrounds.
The imagecreate() function is used to create a new image. It is preferred to use imagecreatetruecolor() to create an image instead of imagecreate().
$file = '../image.jpg'; $type = 'image/jpeg'; header('Content-Type:'.$type); header('Content-Length: ' . filesize($file)); readfile($file);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With