Check if a file exists on another domain

PERL:

Use LWP::Simple and the head function.

use LWP::Simple;

my $url = 'http://some.server.com/file.gif';

if (head($url)) {
# file is there
} else {
# file is missing
}

Credit goes to perlmonks.org.

PHP:

Use get_headers

$fileUrl = 'http://some.server.com/file.gif';
$AgetHeaders = @get_headers($fileUrl);
if (preg_match("|200|", $AgetHeaders[0])) {
# file is there
} else {
# file is missing
}

Credit goes to php.net.

Sphere: Related Content

Related Posts

Leave a Reply