Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8710049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:31:23+00:00 2026-06-13T04:31:23+00:00

My current document root is this (via $_SERVER[‘DOCUMENT_ROOT’]): /var/www/html/clients/app/folder I need to generate one

  • 0

My current document root is this (via $_SERVER[‘DOCUMENT_ROOT’]):

/var/www/html/clients/app/folder

I need to generate one folder up:

/var/www/html/clients/app

How would I go about doing this?

I had asked this in the past:
Dynamically finding paths, is there a better way?

However, I have this scenario which doesn’t work:

  • Executed script is located here: root/f1/f2/f3/f4/f5/file.php.
  • This script includes another script located here: root/f6/file2.php

In file2.php, I needed the following code for this to work:

$base_path = dirname(realpath("../../../../do_not_remove.txt"));

When in theory, based on its location, it should have been this:

$base_path = dirname(realpath("../do_not_remove.txt"));

In practice, there would be a global available where this data could be passed. However, in this inherited project, there isn’t thus I’m reusing this where I need it.

Update #1

Based on the answers, this seems to work great: realpath($_SERVER['DOCUMENT_ROOT']."/../../");

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:31:24+00:00Added an answer on June 13, 2026 at 4:31 am

    well you could have – $_SERVER['DOCUMENT_ROOT'] ."/../" – even though it doesn’t look too pretty

    OR a slightly more propper way might be – dirname( $_SERVER['DOCUMENT_ROOT'] ) – think this should work

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My document root is /var/www and I have no virtual hosts enabled. This is
<script> $(document).ready(function() { $('a.panel').click(function () { $('a.panel').removeClass('selected'); $(this).addClass('selected'); current = $(this); $('#slidewrapper').scrollTo($(this).attr('href'), 300); return
I have this site that I need to find the root folder / plus
I rely heavily in $_SERVER[DOCUMENT_ROOT] to get absolute paths. However this doesn't work for
How can I display the last time the current document was updated in PHP?
I have the following code that creates a submenu based on current document. The
How can I access current xml document uri in XSLT?
activeElement property of the document object sets current element that has the keyboard focus.
Current function: function SetPopup() { x$('body').setStyle('overflow', 'hidden'); x$('#divOne').setStyle('height', document.body.offsetHeight + 'px'); x$('#divOne').setStyle('width', 100 +
I need a java script function that converts the document object of the current

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.