Jump to content

file exists on a remote server


dadamssg

Recommended Posts

What's the proper way to check if a file exists on a remote server? I know file_exists() works for you local files.

 

I think i need to use something like the following. BUT if the file is not found PHP throws a warning. I know i can put a '@' before fopen() but that just masks the error.

 

<?php
if(fopen("http://www.othersite.com/imageXYZ.jpg", "r"))
{
echo "File exists.";
}
else
{
echo "File does not exist.";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/260165-file-exists-on-a-remote-server/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.