7

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?

1 Answer 1

16
dirname($_SERVER["DOCUMENT_ROOT"]);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.