Hey guys I need to write a script that can detect if a remote image exists.

For example detecting this ebay logo, http://pics.ebaystatic.com/aw/pics/homepage/v2/logo_171x102.gif

Is there any code where I can enter a URL of a file (more specifically an image) in and detect if it exists or not and if it doesn't replace it with a local image?

When I was playing around with thumbnailing images before I coulda sworn there was a function or way of doing this but I cant seem to remember it or find info on it.

Any help much appreciated.

    you can use http://php.net/getimagesize it will return false if the remote image doesnt exist and return some extra info to you about the image if it does exist. otherwise you can just try to fopen the image and fopen will return false if the file doesnt exist, however you will have some trouble if some servers do 404 redirects.

      Write a Reply...