Jump to content


Photo

Show if image exists


  • Please log in to reply
1 reply to this topic

#1 Iryk

Iryk
  • Members
  • PipPip
  • Member
  • 25 posts

Posted 18 April 2006 - 11:09 PM

<?
$color = poop;
$species = aisha;
$url = "http://images.neopets.com/pets/".$species."_".$color."_baby.gif";
if(!is_readable($url)) {
$size = getimagesize("$url");
$width = $size[0];
if($width == "150") {
echo "<img src='$url'>";
}
}
?>

Error:
Warning: getimagesize(http://images.neopet...a_poop_baby.gif) [function.getimagesize]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /fpgs/fpgshttpd/majestic-neo/pet_db/pets.php on line 6

I want the script to find out if the image really does exist then if it does it will show the image. But if the image doesn't exist then it will show nothing. Xould someone please tell me what I am doing wrong.

#2 acey99

acey99
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 18 April 2006 - 11:19 PM

cause getimagesize doesn't use http protocol, it uses folder strucure:

eg:

c:\path\to\image\ (Windows)
or /path/to/image (Nix)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users