473,378 Members | 1,467 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,378 software developers and data experts.

PHP doesn't access root directory using forward slash "/"

Hi All,

We are trying to figure out why PHP's file handling functions refuses to
access the web root using the "/" character on our Windows machines. For
example, a file /test.php is located in our web root. A file in a
subdirectory, say /example/runme.php needs to find out if the file
"/test.php" exists. One would expect that the function
file_exists("/test.php") would return true (it does on our unix host).
However, it returns false on our Windows machine.

Unfortunately we can't build a workaround as it is not us but oscommerce
that uses the "/" method to refer to the web root, and modifying all the
oscommerce scripts is simply impractical.

Any pointers would be greatly appreciated,

Regards,

ECRIA Dev. Team

Details:
Apache 2.0.52
PHP 5.0.3
Windows XP Pro SP2
Aug 1 '06 #1
2 8497
Jay
Hi

On Windows this is not a valid Path "/test.php". If you want to test
for a file aon the
local directory use "./test.php" otherwise if you want to test for a
file on your web root you should set a specific DOCUMENT ROOT depending
on your webroot in apache. Then you could use

if(file_exists($_SERVER['DOCUMENT_ROOT']."/test.php"){
echo "Yipee;
}
Good luck
ECRIA schrieb:
Hi All,

We are trying to figure out why PHP's file handling functions refuses to
access the web root using the "/" character on our Windows machines. For
example, a file /test.php is located in our web root. A file in a
subdirectory, say /example/runme.php needs to find out if the file
"/test.php" exists. One would expect that the function
file_exists("/test.php") would return true (it does on our unix host).
However, it returns false on our Windows machine.

Unfortunately we can't build a workaround as it is not us but oscommerce
that uses the "/" method to refer to the web root, and modifying all the
oscommerce scripts is simply impractical.

Any pointers would be greatly appreciated,

Regards,

ECRIA Dev. Team

Details:
Apache 2.0.52
PHP 5.0.3
Windows XP Pro SP2
Aug 1 '06 #2
On Tue, 1 Aug 2006 07:57:43 -0400, "ECRIA" <ph**************@ecria.comwrote:
>We are trying to figure out why PHP's file handling functions refuses to
access the web root using the "/" character on our Windows machines. For
example, a file /test.php is located in our web root. A file in a
subdirectory, say /example/runme.php needs to find out if the file
"/test.php" exists. One would expect that the function
file_exists("/test.php") would return true (it does on our unix host).
However, it returns false on our Windows machine.

Unfortunately we can't build a workaround as it is not us but oscommerce
that uses the "/" method to refer to the web root, and modifying all the
oscommerce scripts is simply impractical.
file_exists works in the filesystem space, not the URL space of the webserver.
"/" never refers to the web root (unless your webserver was chroot'ed to the
web root, which would be unusual); it's the filesystem root.

On Windows this is further complicated because there are multiple roots, one
per drive; "/" is a relative path on Windows, not an absolute path - relative
to the drive of the current working directory.

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Aug 1 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

30
by: Stephen Ferg | last post by:
I have a question that is not directly Python-related. But I thought I'd ask the most erudite group that I know... :-) When did Windows start accepting the forward slash as a path separator...
4
by: Greg Lindstrom | last post by:
Greetings- I am running Python 2.3.3 on HP-UX and would like to access an Oracle 9i database. Looking through the vaults, I see 4 or 5 modules that might work and was wondering if anyone is...
0
by: Ryan Schefke | last post by:
------=_NextPart_000_0077_01C34C8B.2B90C960 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit ..I just sent this out to the win32 distribution list but no one has...
10
by: Kenneth P | last post by:
Hi all, I have an Access database and try to create a connection to it using the Server.MapPath method. I have the app lib in c:\inetprub\wwwroot\apps\myApp and the database in...
1
by: John Dalberg | last post by:
I have an asp.net app that is in a folder which is two levels under the website root folder. The website has a login.aspx which is in the root folder. How do I get the relative path to the web...
19
by: Steve Franks | last post by:
I am using VS.NET 2005 beta 2. When I run my project locally using the default ASP.NET Development Web Server it runs using a root address like this: http://localhost:11243/testsite/ However...
9
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
6
by: littlelisper | last post by:
I want to open an XML file with my browser. The file contains the following line: <?xml-stylesheet type="text/xsl" href="/new.xsl"?> which points to the root node to look for the stylesheet....
5
by: lisles | last post by:
i have a page funtion.php which hs the function to connect to the db /* Mysql Connection */ function connect(){ global $db_server,$db_user,$db_pass,$db;//Global Values from the config.php...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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

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.