|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2010-10-07 15:51 UTC] saurabh0 at gmail dot com
 Description:
------------
Running PHP Version 5.3.3 (FastCgi, non-thread safe) on IIS6/Windows Server 2003.
All file functions give error when relative paths are used and with *only* Read permissions on the folder. e.g.
file_get_contents('./path/file.txt');
The above gives:
Warning: file_get_contents(./path/file.txt): failed to open stream: No such file or directory
If you give the full path to the same file it works fine. i.e. the follow works:
file_get_contents('C:/full/path/file.txt');
If you add "List Folder Contents" permission to the folder it starts to work with relative folders as well.
I am guessing the when relative paths are used php tries to get some information about the current folder which fails as the "List Folder Contents" is not given. There is no need to "List Folder Contents" just to read a file (even if the path is relative).
This bug has been reported before but not fixed:
http://bugs.php.net/bug.php?id=50163
Note: I had php (5.2) running as ISAPI before and didn't have this problem. So it seems to be specific to non-thread safe version.
Test script:
---------------
file_get_contents('./path/file.txt');
Expected result:
----------------
No error
Actual result:
--------------
Warning: file_get_contents(./path/file.txt): failed to open stream: No such file or directory
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 14:00:01 2025 UTC | 
Some additional info: var_dump(getcwd(), realpath(".")); gives: string(7) "c:\php5" string(7) "C:\php5" As expected, when you give "List Folder Contents" permission (in addition to read) to the web root folder both functions return the correct path.