473,800 Members | 2,696 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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($f ilename)) {
print("The file $filename exists<br>");
} else {
print("The file $filename doesn't exists<br>");
}
############### ############### ###############
?>
Jul 17 '05 #1
3 7972
ba****@hotmail. com (annie) wrote in message news:<5b******* *************** ****@posting.go ogle.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($f ilename)) {
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.goog le.com...
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
4532
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
3761
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. clearstatcache(); if(file_exists("$BasePath/$FileName.jpg")){ $extra=1; while(file_exists("$BasePath/$FileName-$extra.jpg")){
1
2285
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: $image = "../../artimages/".$item_code.".jpg"; if (file_exists($image))
12
11891
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 sure the filename/path is Ok $filename= '//print-admin/Public$/planningprepress/planning/prepresslist.xls' I've tried replacing all the '/' with chr(92) to no avail. The only
6
2788
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 value.this always show "file doesn't exists' my environment is win2003+iis+php5 how to fix it ?
2
1977
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 not in /home/user/files/ scripts/ where the original file is been executed from: 00 20 * * 1 /usr/local/bin/php /home/user/files/scripts/check.php /
15
9115
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 it returns a value of null instead of true or false. It seems to work great if I check for something in the base directory, but when I try something outside of the root, it fails. The check file code looks like this: if (file_exists($filename)) { ...
5
13131
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 typical scenario of wanting to check for an image files existence before displaying, I have foubd the following code to do this but it always returns false: $imageURL = "http://website.com/images/image1.jpg"; $handle =...
9
2134
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. What am I doing worng?
0
9691
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10255
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10036
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9092
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7582
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6815
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5607
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2948
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.