php file_exists() return false on some directory on IIS
Environment:
- php5
- windows2003
- IIS with fastCGI 开发者_如何学Go
Code:
<?php
$p = "i:\\tmp";
if( file_exists($p) )
{
print $p . ' exists!';
}
else
{
print $p . ' not exists!';
}
?>
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.
Make sure that directory is readable by checking it's permissions (chmod).
Alternatively, you might try using
is_readable()
function.
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.
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
精彩评论