EchoFool Posted May 11, 2009 Share Posted May 11, 2009 Hi, I am wondering if there is a way in php to check if an url uploaded by a user is valid... and that the url points to an image only. Say for example i want to show a image hosted on photobucket, the url given would be http: etc etc .jpg But firstly i need php to know does that url point to anything, then secondly does it point to an image. Was wondering if php can check this kind of thing, is there a crude example of hows its done, then i can work off it to manipulate it to work into my site.. Hope you can help. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 11, 2009 Share Posted May 11, 2009 cURL Quote Link to comment Share on other sites More sharing options...
EchoFool Posted May 11, 2009 Author Share Posted May 11, 2009 Hmm the list there doesn't suggest anything to do with checking if url exists :S Although the terminology is throwing me... How does it check if the url exists and what does it return to tell the script if it exists or not ? Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 11, 2009 Share Posted May 11, 2009 Really!? I'll give you one last look before I slap you. No offense intended. Just playing with you. But really, click the functions there and you'll find the one you need. Quote Link to comment Share on other sites More sharing options...
DarkSuperHero Posted May 11, 2009 Share Posted May 11, 2009 <?php $hosts = gethostbynamel('www.example.com'); print_r($hosts); ?> Returns the IPv4 address or a string containing the unmodified hostname on failure. theres also.. gethostbynamel gethostbyaddr gethostbyname http://us2.php.net/manual-lookup.php?pattern=host Quote Link to comment Share on other sites More sharing options...
EchoFool Posted May 11, 2009 Author Share Posted May 11, 2009 Right ok i didn't see that function in the list. With regards to gethostbynamel, do these expand into check if the url points to a image format ? Or will i need a seperate function for that aswell? Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 11, 2009 Share Posted May 11, 2009 http://us2.php.net/manual/en/function.curl-getinfo.php That's what you want. And if you know about HTTP_CODE, you should be fine. Otherwise, read up on them. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.