Is it possible to load a image using:
?
for image.php
:
$ima
You have to change the header content-type and print the contents of the image file. Here is an example for your image.php file:
$image_id = $_GET['image_id'];
$filename = "image".$image_id.".png";
header('Content-Type: image/png');
print file_get_contents($filename);
one liner....
echo (file_exists($_GET['image_id'])) ? header("Content-Type:image/png").readfile($_GET['image_id']).die() : false;
Is it possible to load a image use:
<img src="image.php?image_id=1">
Yes. URLs are URLs. It is content-type that determines content, not any characters in the URL itself.
$image_id = $_GET['image_id'];
echo "image".$image_id.".png";
Not like that. You either have to read the image file in and then output it with a suitable content-type, or redirect (with a location header) to a static image.
No, this is not possible that way. You would have to write the contents of the image file to the output stream instead.
If you have the png contents in the database, follow the other answers. If all you need is the id from the database, simply <img src="image<?=$image_id?>.png">
you must return a valid image, use file_get_contents or readfile for get the conent of image then output to browser
header("Content-Type:image/png");
$image_id = $_GET['image_id'];
if(is_file($file = "image".$image_id.".png") || is_file($file = "no_image.png"))
readfile($file);