[solved] check if an image file exists before getting info
Posted: Wed Aug 23, 2006 2:39 pm
I have a site that links to external images. When someone specifies the url where their image is, I tried to use getimagesize() or exif_imagetype() to determine whether it is a valid image or not. Well, if the file exits, these functions do a great job at determining file types (albiet VERY slowly [sometimes over 1.5 seconds]). But, if the user gives me a url that doesnt even exist, both of the aforementioned functions produce errors. Error shown here:
Warning: exif_imagetype(http://www.lalala.com/images/foo.jpg) [function.exif-imagetype]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in...yada yada
Is there a function that will check if the url even exists before I run imagesize on it?
Warning: exif_imagetype(http://www.lalala.com/images/foo.jpg) [function.exif-imagetype]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in...yada yada
Is there a function that will check if the url even exists before I run imagesize on it?