php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29723 file_get_contents() fails with the file:// wrapper
Submitted: 2004-08-17 23:45 UTC Modified: 2004-08-31 13:41 UTC
From: vma1 at abv dot bg Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 5CVS-2004-08-17 (dev) OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: vma1 at abv dot bg
New email:
PHP Version: OS:

 

 [2004-08-17 23:45 UTC] vma1 at abv dot bg
Description:
------------
When file_get_contents() is used under Windows with the file:// wrapper, it gives the following error:
Warning: file_get_contents() [<function.file-get-contents>]: remote host file access not supported

The bug is caused by the following code in main/streams/streams.c (for PHP5-200408171230 it is on line 1457).

		if (protocol && path[n+1] == '/' && path[n+2] == '/' && path[n+3] != '/')	{
			if (options & REPORT_ERRORS) {
				php_error_docref(NULL TSRMLS_CC, E_WARNING, "remote host file access not supported, %s", path);
			}
			return NULL;
		}

The condition path[n+3] != '/'  works for UNIX filesystems only. On Windows absolute path does not start with a /, but a drive letter followed by ":", e.g. D:\projects\...

Reproduce code:
---------------
file_get_contents ("D:\projects\index.tpl");


Expected result:
----------------
No error messages.


Actual result:
--------------
Warning: file_get_contents() [<function.file-get-contents>]: remote host file access not supported...


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-19 21:15 UTC] vma1 at abv dot bg
The reproduce code should be:
file_get_contents ("file://D:\projects\index.tpl");
 [2004-08-31 13:41 UTC] tony2001@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Should be fixed both for 5.1.x & 5.0.x.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 21:01:35 2025 UTC