Jump to content

file exists function returning wrong result


dflow

Recommended Posts

i have this script:





<?php
$filename = 'http://website.com/images/logo.gif';

if (file_exists($filename)) {
    echo "The file $filename exists";
} else {
    echo "The file $filename does not exist";
}
?>

i get the else result echoed although the image exists

 

any ideas?

 

 

 

 

 

 

Read : http://www.php.net/manual/en/function.file-exists.php as some people already posted some code workaround for file_exists() (with URL) to work with older php version. Some with cURL, get_headers() or fsockopen().

 

New php version >= 5.0.0 seem to natively support http protocol with file_exists() function though i never try that. I always used file_exists() only for local file and a home made version for testing URL.

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.