Your first solution doesn't work because the html image tag expect the image data and not the image url.
I can't use your second solution because I'm generating the image tag dynamicaly on the client side.
I finally used the header function:
[PHP]header('Location:'.$image_url);[/PHP]
The problem is that I need to cache the image.
Can I load the image data in the php script, add expire header and then echo it?
Thanks
Assuming that the picture is stored somewhere (so you only need the path to it).
Then it would be enough to echo the file path.
[PHP]$id = $_GET["id"];
$img_url = someFunction($id);
echo $img_url;[/PHP]
but why calling another script file... since you're starting from a php file anyway you could do also
[PHP]include_once("phpScript.php");
echo '<img src="' . someFunction(12321321) . '" alt=""/>';[/PHP]
regards