Page 1 of 1
Accessing above document root.
Posted: Mon Sep 29, 2008 11:49 am
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.
Re: Accessing above document root.
Posted: Mon Sep 29, 2008 1:11 pm
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.
Re: Accessing above document root.
Posted: Mon Sep 29, 2008 1:16 pm
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.
Re: Accessing above document root.
Posted: Mon Sep 29, 2008 1:19 pm
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.