Accessing above document root.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
markusn00b
Forum Contributor
Posts: 298
Joined: Sat Oct 20, 2007 2:16 pm
Location: York, England

Accessing above document root.

Post by markusn00b »

Say you have a directory, safe, that is outside the public folder, www -- both of these are under the location of C://lhost/. How do I get to the directory safe? I know you can do '../' but I have to assume that we could be on any level of the directory tree. Is there anything like $_SERVER['DOCUMENT_ROOT'] that will give you the directory lhost?

Cheers.
User avatar
The_Anomaly
Forum Contributor
Posts: 196
Joined: Fri Aug 08, 2008 4:56 pm
Location: Tirana, Albania

Re: Accessing above document root.

Post by The_Anomaly »

I'm not sure if this answers you question, but at least in Linux you can use concrete paths, i.e. "/var/www/test.php." In your case, I'd imagine that it would be "c:/lhost/safe/test.php." Although, if you're asking for a PHP function that gets the parent of the document_root, I wouldn't know.
User avatar
markusn00b
Forum Contributor
Posts: 298
Joined: Sat Oct 20, 2007 2:16 pm
Location: York, England

Re: Accessing above document root.

Post by markusn00b »

The_Anomaly wrote:I'm not sure if this answers you question, but at least in Linux you can use concrete paths, i.e. "/var/www/test.php." In your case, I'd imagine that it would be "c:/lhost/safe/test.php." Although, if you're asking for a PHP function that gets the parent of the document_root, I wouldn't know.
You have given me enough info to help.

I could just store 'c://lhost/' in a constant and then change it accordingly on different servers.

Cheers.
User avatar
The_Anomaly
Forum Contributor
Posts: 196
Joined: Fri Aug 08, 2008 4:56 pm
Location: Tirana, Albania

Re: Accessing above document root.

Post by The_Anomaly »

markusn00b wrote:
The_Anomaly wrote:I'm not sure if this answers you question, but at least in Linux you can use concrete paths, i.e. "/var/www/test.php." In your case, I'd imagine that it would be "c:/lhost/safe/test.php." Although, if you're asking for a PHP function that gets the parent of the document_root, I wouldn't know.
You have given me enough info to help.

I could just store 'c://lhost/' in a constant and then change it accordingly on different servers.

Cheers.
Glad I could help :)

I would be interested though if any other members have a better way of doing this, perhaps through some PHP function I don't know about.
Post Reply