From:             bg at rjservices dot com
Operating system: n/a (fails on linux/win32)
PHP version:      4.3.4
PHP Bug Type:     Filesystem function related
Bug description:  file_exists() does NOT work with absolute paths.

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)

-- 
Edit bug report at http://bugs.php.net/?id=28032&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28032&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28032&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28032&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28032&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28032&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28032&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28032&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28032&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28032&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28032&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28032&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28032&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28032&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28032&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28032&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28032&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28032&r=float

Reply via email to