Reputation: 49
<?php
$p = "i:\\tmp";
if( file_exists($p) )
{
print $p . ' exists!';
}
else
{
print $p . ' not exists!';
}
?>
Upvotes: 0
Views: 3100
Reputation: 49
I get it:
when use
file_exist()
to test an existing directory, if parent directory has no read permission of IUSR_MACHINE, the test always fails.
Upvotes: 2
Reputation: 53929
If you are running PHP in safe mode then File_Exists will always return FALSE for files inaccessible due to safe mode restrictions.
Also note that the File_Exists caches it's result, so you might wan't to clear the cache with the ClearStatCache function
Upvotes: 0
Reputation: 19247
what does your code looks like? if you're testing with a string literal, don't forget that backslashes introduce escape sequences:
file_exists("D:\rip\this\nipple")
here \r
is a carriage return, \t
a tab, and \n
a line feed.
Upvotes: 1
Reputation: 382806
Make sure that directory is readable by checking it's permissions (chmod).
Alternatively, you might try using
is_readable()
function.
Upvotes: 1