|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53011 Error using relative paths are used with *only* Read permissions
Submitted: 2010-10-07 15:51 UTC Modified: 2010-10-07 17:45 UTC
From: saurabh0 at gmail dot com Assigned:
Status: Duplicate Package: Filesystem function related
PHP Version: 5.3.3 OS: Windows Server 2003
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: saurabh0 at gmail dot com
New email:
PHP Version: OS:


 [2010-10-07 15:51 UTC] saurabh0 at gmail dot com
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.


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:


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:

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:

Expected result:
No error

Actual result:
Warning: file_get_contents(./path/file.txt): failed to open stream: No such file or directory


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-07 16:08 UTC] saurabh0 at gmail dot com
Some additional info:

var_dump(getcwd(), realpath("."));


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.
 [2010-10-07 17:45 UTC]
-Status: Open +Status: Duplicate
 [2010-10-07 17:45 UTC]
Closing as duplicate of bug #50163. Continue the discussion there, as Pierre has it picked it up over there.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 17 23:01:27 2024 UTC