If you want to use something like this :
Then temp.php
should actually :
- send HTTP-headers for some image content-type
- and send the actual content of the image.
This is because the browser expects that the URL pointed to by the src
attribute of the <img>
tag actually corresponds to a valid image -- and not some HTML text.
For instance, temp.php
could contain something like this :
<?php
$key = $_GET['key'];
// TODO : security check on $key !!!
$file = 'images/logo-' . $key . '.jpg';
header('Content-type: image/jpeg');
readfile($file);
?>
As a couple of sidenotes :
- You must send the right
Content-type
HTTP header ; which means you must know if your image is a gif, jpeg, png, ...
- You must check if
$_GET['key']
is correct, to not send the content of an un-wanted file !
- There should be absolutly no white-space character before or after the
<?php ... ?>
tags : the only output must be the content of the image.