...

View Full Version : Verify the existance of a URL?



AaronW
10-01-2004, 08:50 PM
I've got a field that takes a URL in the form of 'http://.../somefile.jpg' (without quotes) and I'd like to somehow check that the URL to the image they've provided returns an actual image file. Is there any other way to do this, other than fopen ($_POST['url'])? Even using fopen(), would I be able to assure that the file returned is actually a JPEG?

Any suggestions would be greatly appreciated. In the meantime, I'll just allow broken URLs.

Thanks,
Aaron

firepages
10-02-2004, 03:35 AM
I think fopen() ,file() or file_get_contents() etc is the quickest way , as to the mime-type there is no way you can check this until you have the file on your system (other than simply assuming the extension is correct!) as you can't perform file operations on remote files.

jamescover
10-02-2004, 04:40 AM
I've got a field that takes a URL in the form of 'http://.../somefile.jpg' (without quotes) and I'd like to somehow check that the URL to the image they've provided returns an actual image file.


If you mean a form field, check out these threads:


http://www.codingforums.com/showthread.php?t=45398


http://www.codingforums.com/showthread.php?t=45438


-james

ReadMe.txt
10-02-2004, 11:39 AM
getimagesize() (www.php.net/getimagesize)

Exactly what you are looking for.

AaronW
10-02-2004, 12:53 PM
Ah! That's right! getimagesize () can do remote files. Sweet. Thanks :)

Thanks to the others, too. And they aren't uploading the file, they're just typing a URL.

jamescover
10-02-2004, 02:02 PM
Thanks to the others, too. And they aren't uploading the file, they're just typing a URL.

Same difference.



-james

firepages
10-02-2004, 03:29 PM
getimagesize() (www.php.net/getimagesize)

Exactly what you are looking for.


ok! well that shuts me up :D , well spotted



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum