Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP File Directory - $_SERVER['DOCUMENT_ROOT']'s parent folder

I know $_SERVER['DOCUMENT_ROOT'] returns the document root (most likely something like /home/user/public_html), but is there any way to get the parent directory of this folder? (i.e. just /home/user/)

I would try and replace common folder names like public_html or www, but it's not a given that the folder would be named that on all systems I want this code to run on.

FYI: I'm trying to implement this, but i want the user to be able to select their FTP root folder, which is most commonly the parent of the Document Root folder.

Any thoughts?

like image 598
Andrew E. Avatar asked Sep 03 '09 03:09

Andrew E.


1 Answers

dirname($_SERVER["DOCUMENT_ROOT"]);
like image 123
typeoneerror Avatar answered Oct 12 '22 00:10

typeoneerror