Jump to content

Backing up to the root with ..\ does not work on some ISP's. What do you use?


Phrank

Recommended Posts

I have a directory structure like:

 

root

---> somepages

---> someincludes

 

I have a webpage 'somepages\mypage.php' and in that page I have an include "..\someincludes\abcinlcude.php"

 

This works for some isp's. the ..\ take me back to the root. For other isp's it takes me too far back like 'user\blah\blah\root' and of course the "..\someincludes" fails.

 

How do you get around this?

 

Any help would be greatly appreciated. TIA

"../" as it should be will take you back one level. If you do not use the .. you will start from the actual root of you host as you described below.

 

so "../someincludes/abcinclude.php" will go back one level

 

"/someincludes/abcinclude.php' will look for the folder "someincludes" in the actual root directory not the root of the web

 

when working with paths in html always use forward slash "/" even on a windows box it will be fine.

 

Ray

Leading ./ or ../ are relative to the CWD (current working directory) in an include() (according to the manual.) The CWD is one of those gray undocumented areas where you don't really know what it could be depending on how your script was reached (directly or being included by another file...)

 

I recommend forming absolute file system paths using $_SERVER['DOCUMENT_ROOT']

 

include($_SERVER['DOCUMENT_ROOT'] . '/your_path/your_file.php');

 

This will work independently of any CWD value or any include_path settings or differences between servers.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.