I would like to display an image through a PHP script so that you have a normal img in html but with a source of a php script. This script would then open an existing png or jpg image and display that image through it.
I have been trying this code with no luck at present.
$img = imagecreatefrompng("logo.png");
header("Content-type: image/png");
imagepng($img);
imagedestroy($img);
No errors the image output is broken.
Thanks in advance.
header("Content-type: image/png");
readfile("$file");
exit;
it is good idea to add some headers, like:
header('Expires: 0');
header('Content-Length: ' . filesize($file));
look at discussion here: http://php.net/manual/en/function.readfile.php
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