user3629541
user3629541

Reputation:

function file_exists does not work

In my webroot, i have a file called exists.php in which is this code to check if a file exists:

$filename = 'http://www.domain.nl/contact.php';
if (file_exists($filename))
    {
        echo "Document ".$filename." found...<br><br><br>";
    }
    else
    {
        echo "Document ".$filename." not found...<br><br><br>";
    };

The file contact.php DOES exist but when calling exists.php he echoes: Document not found
When changing code to this:

$filename = 'contact.php';
if (file_exists($filename))
    {
        echo "Document ".$filename." found...<br><br><br>";
    }
    else
    {
        echo "Document ".$filename." not found...<br><br><br>";
    }; 

Then it echoes: Document found.

Why does this not work with an absolute path?

Upvotes: 0

Views: 207

Answers (1)

Mark Baker
Mark Baker

Reputation: 212522

file_exists() only works on stream wrappers that support the stat function.

These include:

  • file://
  • ftp://
  • php://memory
  • php://temp
  • phar://
  • ssh2.sftp
  • rar://

http:// is not supported

Upvotes: 3

Related Questions