php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28032 file_exists() does NOT work with absolute paths.
Submitted: 2004-04-16 21:33 UTC Modified: 2004-04-16 21:55 UTC
From: bg at rjservices dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 4.3.4 OS: n/a (fails on linux/win32)
Private report: No CVE-ID: None
 [2004-04-16 21:33 UTC] bg at rjservices dot com
Description:
------------
I have searched the bug reports, and have seen other reports of this problem that were closed; however they were pretty old, and the bug persists.

BUG:
If an absolute path is used with the file_exists() function, it will ALWAYS report the file doesn't exist.
ie: file_exists('/images/mypic.gif') ALWAYS reports false.

Only by specifying a relative path, will the function start working.

Although my ISP is still running php 4.2.3, I've checked the change log, and there is no indication that this bug has been addressed.
I have no control over my ISP, and therefore no ability to upgrade; however, as I've said, there is nothing in ANY of the changelogs to indicate this bug has been addressed.


Reproduce code:
---------------
here is sample code illustrating the problem:
you may observe the code here (and get source):
http://www.rjservices.com/bugs/fileexist.php

<html><body><BR>
this file is using php's  file_exists() function to look at itself.<br>
the function ONLY works correctly if a RELATIVE path for the filename is used!<br>
if an absolute path is used, is ALWAYS reports the file doesn't exist!<br>
<?php
$g="../bugs/fileexist.php";
$b="/bugs/fileexist.php";
if (file_exists($g)) $t="true"; else $t="false";
print "\n<BR>good file is ".$g." and it exists? - ".$t;
if (file_exists($b)) $t="true"; else $t="false";
print "\n<BR>bad file is ".$b." and it exists? - ".$t;
?>
<BR><BR>
here's the code used in this file:
<a href="http://www.rjservices.com/bugs/fileexist.php.txt">fileexist.php</a>
<br>
This system is running PHP 4.2.3, and 	Apache/1.3.23<br>
and runs on (Red-Hat/Linux)  PHP/4.2.3 <br>
</body></html>


Expected result:
----------------
file_exists("/bugs/fileexist.php") SHOULD return TRUE;
it doesn't. (and the file DOES exist:)


Actual result:
--------------
file_exists("/bugs/fileexist.php") returns FALSE;
(and the file DOES exist)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-16 21:55 UTC] sniper@php.net
file_exists() works on the file-system level..

Please ask further support questions on the appropriate mailing list.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jun 26 12:01:28 2024 UTC