Hello all,
I was wondering if it is possible to check if a file exists on a remote server using php. For example I would like to create a simple funcion that for a given input "www.anyserver.com/anyfile.htm" returs true if the file exists or false otherwise. If it is possible can anybody tell me how to do it?
Thanks,
-Pharmacomancer
File on remote server
Moderator: General Moderators
-
reverend_ink
- Forum Contributor
- Posts: 151
- Joined: Sun Apr 20, 2003 1:18 am
- Location: Las Vegas | London
Code: Select all
<?php
if (file_exists("http://www.anydomain.com/anyfile.htm")){
echo ("whatever");
}
else {
echo ("whatever else");
}
?>Not sure you can use file_exists on remote urls. So you could also do:
Code: Select all
$foo = file('http://foo.com/bar.php');
if(!empty($foo)){
//it exists
} else {
//it doesn't
}