i am trying to get the document root path, up one level...

IE

/home/user/public_html

and i just want

/home/user

i thought about using $_SERVER[DOCUMENT_ROOT] and then stripping the last forwardslash and whatever came after it, i am just not quite sure how to do that...

thanks

    $path_to_dir_above_root = $_SERVER['DOCUMENT_ROOT'] . '/../';

      ... which refers to the directory above the document root.

      Do you need the actual path? If you're doing some sort of file IO operation, then that path should resolve just fine. If you actually want to display the path (e.g. for the user's benefit), then you could use something like [man]realpath/man to resolve the '../' bit.

      EDIT: You could also use [man]dirname/man on $_SERVER['DOCUMENT_ROOT'] itself, assuming that an ending '/' isn't present.

        Don't forget to mark this thread resolved (if it is) using the link on the Thread Tools menu.

          Write a Reply...