开发者

php file_exists() return false on some directory on IIS

Environment:

  1. php5
  2. windows2003
  3. IIS with fastCGI
  4. 开发者_如何学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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜