PHPNewbie55 Posted November 30, 2008 Share Posted November 30, 2008 I am trying to check and see if an image file exists on another server... Basically if the file exists I want to show the file.. if not I want to show a 404 Image instead... But the file_exists("") only seems to work on my server and won;t accurately check if a file exists on another... Example /// if the file_exists is checking for a file on my server it works fine. file_exists("images/someimage.gif"); /// but if I try to check another server it won't work. file_exists("http://www.doman.com/images/someimage.gif"); Is there a way to check if an image or file exists on another server...??? Link to comment https://forums.phpfreaks.com/topic/134807-checking-to-see-if-an-image-exists-on-another-server/ Share on other sites More sharing options...
cooldude832 Posted November 30, 2008 Share Posted November 30, 2008 you can try to read the file via GD and if you can't you know it isn't an image or not there however its rude and against most rules to hotlink without the right to Link to comment https://forums.phpfreaks.com/topic/134807-checking-to-see-if-an-image-exists-on-another-server/#findComment-701991 Share on other sites More sharing options...
PHPNewbie55 Posted November 30, 2008 Author Share Posted November 30, 2008 Oh I am not hotlinking... lol... But what do you mean by: "read the file via GD" Link to comment https://forums.phpfreaks.com/topic/134807-checking-to-see-if-an-image-exists-on-another-server/#findComment-702001 Share on other sites More sharing options...
DarkWater Posted November 30, 2008 Share Posted November 30, 2008 @cooldude: I wouldn't use GD for this. I'd suggest using cURL and retrieving just the headers (not the whole image) so that you can keep page load time to a minimum. Link to comment https://forums.phpfreaks.com/topic/134807-checking-to-see-if-an-image-exists-on-another-server/#findComment-702006 Share on other sites More sharing options...
cooldude832 Posted November 30, 2008 Share Posted November 30, 2008 headers can lie, but I think you are right because GD dies when the headers are wrong Link to comment https://forums.phpfreaks.com/topic/134807-checking-to-see-if-an-image-exists-on-another-server/#findComment-702032 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.