Re: how to verify image and not http error is returned to browser

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Cindy Reeves wrote:
Hi. I want to include an image on my home page that is dynamically created
from another website. The source code on a typical HTML page would be <img
src="http://www.othersite.com/returnedimage.aspx";>

I don't trust their server will always be up/respond, so I want to use a PHP
function to determine whether a GIF has been returned (oppsed to an HTTP
error) before sending it to the browser. Any recommendations how to do this?

<img src="/image.php" />

image.php:
<?php
$image=file_get_contents('http://www.othersite.com/returnedimage.aspx');
if(substr($image,0,3)=='GIF') echo $image;
else readfile('alternate_image.gif');
?>

-Rasmus

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux