Page 1 of 1

File_exists on a a remote server

Posted: Fri Aug 13, 2004 9:45 am
by mzfp2
Hi

I'm having trouble determining if a file eixts oir not a remote server using the following method

if (file_exists('http://remoteserver/image.jpg') == true)
{
}

I can display the image file, and even access its attributes such as height, width and file type, just cannot get the file_exist statement to correctly determine if the file actually exists or not (always returns false).

Any help would be greatly appreciated.

Thanks

Posted: Fri Aug 13, 2004 9:54 am
by Getran
maybe just try it like this ?

Code: Select all

<?php
$check = file_exists('http://remoteserver/image.jpg');
if (isset($check))
{
// w/e
}

?>

Posted: Fri Aug 13, 2004 10:21 am
by d3ad1ysp0rk
Geltran, isset checks whether it was set, file_exists() returns TRUE or FALSE. So your if statement would happen no matter what.

mzfp2:

Code: Select all

<?php
if (file_exists("http://remoteserver/image.jpg")){
  echo "File exists!";
}
else {
  echo "No file..";
}
?>

Posted: Fri Aug 13, 2004 10:30 am
by Getran
i see, well i'm still a nub to PHP anyway :P

Posted: Fri Aug 13, 2004 10:52 am
by m3mn0n
http://www.php.net/manual/en/ will help with that. 8)

Posted: Fri Aug 13, 2004 10:54 am
by Getran
lol