473,402 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

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 7845
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Chann Becker | last post by:
My current setup: WWW Server: Windows 2000 Server, SP4 IIS5 PHP 4.3.4 File Server Windows 2000 Server, SP4
2
by: Andrew Crowe | last post by:
Hi guys, I've created this little function to check whether a user has uploaded a file with the same name as an existing file, and if so rename it to file-1.jpg, file-2.jpg etc. ...
1
by: Hinrich Specht | last post by:
Hello, I have a problem using file_exists. I want to use file_exists to dertermine if a product-image is available or not to show either the product-image or a standard-image. This is the code:...
12
by: Alan | last post by:
Running PHP5 with IIS on a Win2K Server whenever I try file_exists() on a file in a windows share on another server I get a response of False - I can't open the file or do anything with it. I'm...
6
by: +86 | last post by:
i encountered this problem: "include('inc.php')" will work problely but "include('./inc.php') doesn't work .. both file_exists('inc.php') or file_exists('./inc.php') didn't return the right...
2
by: roger.moon2 | last post by:
So I wrote a script to run via crontab but when it tries to check whether a file exists like below: if (!file_exists("settings.ini")) return false; it checks whether the file exists in $HOME...
15
by: cooldht | last post by:
Hi all, I ran into a cool function in a google search, called file_exists that would do exactly what I need it to do. Unfortunately, I think something is wrong with the logic I'm using, because...
5
by: chromis | last post by:
Hi there, This has probably been asked a million times but having looked through the PHP manual for the file_exists() function I can't seem to get the right code for what I want to do. I have a...
9
by: damezumari | last post by:
$file = 'C:\Documents and Settings\Michael\Escritorio\Elvis\test.txt'; file_exists($file) and file_exists('"'.$file.'"') both return false although the file does exist on the user's machine....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.