tags:

views:

415

answers:

4

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!';
}
?>
+1  A: 

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

Alternatively, you might try using

is_readable()

function.

Sarfraz
It's on windows. I add 'everyone' read/write permissions. not working.
madcat
is_readable() and is_dir() both always return false.is_readable - "Tells whether a file exists and is readable." not sure if this will work on directory?
madcat
+1  A: 

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.

just somebody
I took note of that.file_exists("C:\\dir")not working
madcat
A: 

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

Jan Hančič
thx!safe mode is off in php.ini.called ClearStatCache function.still not working with both.
madcat
A: 

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.

madcat
The `open_basedir` might be causing this:http://www.php.net/manual/en/ini.core.php#ini.open-basedir
Tomas Markauskas
will look into this. Look like it! thx!
madcat
open_basedir is not set in php.ini,any idea where else such 'safty' limits can be given?
madcat