madcat
madcat

Reputation: 49

php file_exists() return false on some directory on IIS

Environment:

  1. php5
  2. windows2003
  3. IIS with fastCGI

Code:

<?php
$p = "i:\\tmp";
if( file_exists($p) )
{
    print $p . ' exists!';
}
else
{
    print $p . ' not exists!';
}
?>

Upvotes: 0

Views: 3100

Answers (4)

madcat
madcat

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

Jan Hančič
Jan Hančič

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

just somebody
just somebody

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

Sarfraz
Sarfraz

Reputation: 382806

Make sure that directory is readable by checking it's permissions (chmod).

Alternatively, you might try using

is_readable()

function.

Upvotes: 1

Related Questions