My current root directory of this document (via $ _SERVER ['DOCUMENT_ROOT']):
/var/www/html/clients/app/folder
I need to create one folder up:
/var/www/html/clients/app
How can I do it?
I asked about this in the past: Dynamically finding paths, is there a better way?
However, I have a script that does not work:
- The executed script is 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:
$base_path = dirname(realpath("../../../../do_not_remove.txt"));
If theoretically, based on your location, it should be like this:
$base_path = dirname(realpath("../do_not_remove.txt"));
In practice, there is global availability where this data can be transmitted. However, this legacy project does not, so I reuse it when I need it.
Update # 1
Based on the answers, this looks great: realpath($_SERVER['DOCUMENT_ROOT']."/../../");
source share