Andrew E.
Andrew E.

Reputation: 139

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?

Upvotes: 7

Views: 6148

Answers (1)

typeoneerror
typeoneerror

Reputation: 56958

dirname($_SERVER["DOCUMENT_ROOT"]);

Upvotes: 16

Related Questions