468,760 Members | 1,967 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,760 developers. It's quick & easy.

file_exists alway returns false

Hi

I've got two linux boxes running redhat9 and either PHP Version 4.2.2
or PHP Version 4.3.7. The file structure is set up the same on both
machines and both files exist. The problem is not file specific and
on both machines seq_tables is a symbolic link to another location.

It makes no difference to either version of php whether I use double
or single quotes when asigning a value to $filename. Nor does it
matter whether I use single or double, forward(/) or back(\) slashes
in the path.

I don't use open_basedir in either php.ini file so this warning
doesn't apply. 'If you use open_basedir in php.ini and use file_exists
for file outside open_basedir path, you will not be warned at log and
file_exists returns false even if file really exists.'

So what else could cause the file to be found on the 4.2.2 version but
not on the 4.3.7 version? Any hints will be much appreciated.

Annie


<?php

#####test script############################
$filename = '/var/www/html/seq_tables/lumbricus/sequences/CF610635';

if (file_exists($filename)) {
print("The file $filename exists<br>");
} else {
print("The file $filename doesn't exists<br>");
}
#############################################
?>
Jul 17 '05 #1
3 7354
ba****@hotmail.com (annie) wrote in message news:<5b**************************@posting.google. com>...
Hi

I've got two linux boxes running redhat9 and either PHP Version 4.2.2
or PHP Version 4.3.7. The file structure is set up the same on both
machines and both files exist. The problem is not file specific and
on both machines seq_tables is a symbolic link to another location.

It makes no difference to either version of php whether I use double
or single quotes when asigning a value to $filename. Nor does it
matter whether I use single or double, forward(/) or back(\) slashes
in the path.

I don't use open_basedir in either php.ini file so this warning
doesn't apply. 'If you use open_basedir in php.ini and use file_exists
for file outside open_basedir path, you will not be warned at log and
file_exists returns false even if file really exists.'

So what else could cause the file to be found on the 4.2.2 version but
not on the 4.3.7 version? Any hints will be much appreciated.

Annie

This might sound a bit simplistic, but did you verify if the file
exists via command-line? "ls -l ../myfile"? Also check permissions
on the file, if Apache (or whatever webserver you use) has no
permissions to at least read that file you could return a false on
file_exists() even though the file really does exist (I have run into
that in the past).

Phil

<?php

#####test script############################
$filename = '/var/www/html/seq_tables/lumbricus/sequences/CF610635';

if (file_exists($filename)) {
print("The file $filename exists<br>");
} else {
print("The file $filename doesn't exists<br>");
}
#############################################
?>

Jul 17 '05 #2
I don't think it's just a permissions thing. I believe something is
set to allow the seq_tables directory to be read on PHP Version 4.2.2
or to stop it from being read on PHP Version 4.3.7 but I can't find
anything like this in the ini file. Perhapse it's an apache setting?

see links for example of problem. Any other thoughts appreciated.

http://zeldia.cap.ed.ac.uk/Lumbribase/file_exists.php
and
http://trichuris.cap.ed.ac.uk/Lumbri...ile_exists.php

Annie
Jul 17 '05 #3
I think it's a permission issue. Accessing the URL
http://trichuris.cap.ed.ac.uk/seq_tables/test.txt yields a 403 error.

"annie" <ba****@hotmail.com> wrote in message
news:5b*************************@posting.google.co m...
I don't think it's just a permissions thing. I believe something is
set to allow the seq_tables directory to be read on PHP Version 4.2.2
or to stop it from being read on PHP Version 4.3.7 but I can't find
anything like this in the ini file. Perhapse it's an apache setting?

see links for example of problem. Any other thoughts appreciated.

http://zeldia.cap.ed.ac.uk/Lumbribase/file_exists.php
and
http://trichuris.cap.ed.ac.uk/Lumbri...ile_exists.php

Annie

Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Chann Becker | last post: by
1 post views Thread by Hinrich Specht | last post: by
12 posts views Thread by Alan | last post: by
2 posts views Thread by roger.moon2 | last post: by
9 posts views Thread by damezumari | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.