Hi
I want to check that a remote image file (e.g http:\someserver.com\image.gif) exists. What is the best way to do this?
many thanks in advance
Will
Hi
I want to check that a remote image file (e.g http:\someserver.com\image.gif) exists. What is the best way to do this?
many thanks in advance
Will
The best way would be to open a socket to the desired server, make the http request for the file and see what error you get.
Examples of these are 500 if it's Ok, 404 if it doesn't exist, 403 if you don't have perm, etc.
Thanks Pablo - I'll give it a whirl.
You could use file(). This will get the file into a array.
<?
$success = @file("http:\someserver.com\image.gif");
if ($success)
{
print "File Exists!";
}
else
{
print "File does not exist";
}
Thanks ed. This was a bit easier to get going - althought I think would be slower as I have to check a list of images. Seems to be working okay though. I 'm using it on a banner exchange to check all the banners are valid each morning.
Thanks again
Will