redirecting browser to a new image, with content type image/png in PHP

AuldGit

New Member
I have a php script which generates an image, and is used (mainly) like this:\[code\]<img src="http://stackoverflow.com/questions/2079203/user_image.php?id=[some_guid]" />\[/code\]The script uses a class I wrote to display an image matching that ID. There are a number of things that could go wrong though, and each of them throws an exception. So I have something like this:\[code\]<?phptry { if( ! isset($_GET['id']) ) throw new Exception; $images = new User_Images; $images->display($_GET['id']);} catch( Exception $e ) { header('location: images/link_error.png');}\[/code\]If I view this from the browser, everything is fine -- if there was an error the address in the address bar changes to \[code\]images/link_error.png\[/code\] and displays that instead.But when this script is used in an \[code\]<img>\[/code\] tag, and there is an error grabbing the image, it doesn't show up at all.Do header redirects not work this way? What is another way that I can do this?updateThere is no problem, browser redirects work perfectly this way, the issue was that my browser was caching the empty image that was returned before the redirect was put in. A hard refresh (Ctrl + F5 for Firefox) fixed it and it started working like normal.
 
Back
Top