473,659 Members | 2,666 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 8525
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.comwro te:
>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.

Unfortunatel y 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.u k :: 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
74959
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 character? At one time, it was accepted as a truism that Windows (like MS-DOS) was different from Unix because Windows used the backslash as the path separator character, whereas Unix used the forward slash.
4
2794
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 currently hitting Oracle and what are you using. I get to build a new system from the ground up and the powers that be are allowing me to do it in Python. I'm quite happy. Thanks for your help,
0
3377
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 replied.can someone on this list please help? The issue should be trivial for experienced MySQL users, I'm just a novice, thanks!
10
9024
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 c:\inetpub\dbq\myDB. Using Server.MapPath("../../../dbq/myDB") should as I understand it take me to the myDB lib. But instead I get an error message saying "Cannot use a leading .. to exit above the top directory."
1
5334
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 site root folder (not the curent app folder)? A generic one that works no matter how deep the folder is in the folder heirarchy --
19
10207
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 when I deploy to a remote test server running real IIS, the real root of my application becomes: http://localhost/ What I want to do is have it so that on my local machine the asp.net dev
9
3824
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 site for a small club I belong to and one of the features I would like to include is the ability to allow users to upload image files. unfortunately the servers web root www folder only allows READ and EXECUTE permissions, which makes it...
6
2055
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. Since the XML file is in only-readable media, I cannot modify it, so the solution is to copy the stylesheet to the correct directory. The problem is that I can't find where this should be. I have tried all over the place: in the desktop, in the...
5
9125
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 $conn = @mysql_connect($db_server,$db_user,$db_pass) or die("Connection to Database Server Failed"); @mysql_select_db($db) or die("Database Selection Failed"); return $conn; }
0
8330
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,...
0
8850
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8523
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,...
1
6178
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
5649
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
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2749
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.