Is there anyway to get what directory holds the folder that is accessible via the internet.
Example:
The script on /home/site/public_html/phpscript.php would return /home/site/ because the public_html folder holds the files accessible by internet users.
Filesystem PHP
Moderator: General Moderators
- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
I'm not sure what exactly you're looking for but you might want to try
Code: Select all
<?php
echo 'FILE: ', __FILE__, "<br />\n";
echo 'dirname(FILE): ', dirname(__FILE__), "<br />\n";
echo 'dirname(dirname(FILE)): ', dirname(dirname(__FILE__)), "<br />\n";
echo 'cwd: ', getcwd(), "<br />\n";
echo 'realpath(..): ', realpath('..'), "<br />\n";
echo 'realpath(../..): ', realpath('../..'), "<br />\n";- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
Thanks! I'm gonna try this stuff. What I am looking for is the folder that all the pages that you can view on the internet. So if my files are all in \home\public_html I can get \home\ so i can make \home\protected_html.... I want this for a code installer I'm making.volka wrote:I'm not sure what exactly you're looking for but you might want to tryCode: Select all
<?php echo 'FILE: ', __FILE__, "<br />\n"; echo 'dirname(FILE): ', dirname(__FILE__), "<br />\n"; echo 'dirname(dirname(FILE)): ', dirname(dirname(__FILE__)), "<br />\n"; echo 'cwd: ', getcwd(), "<br />\n"; echo 'realpath(..): ', realpath('..'), "<br />\n"; echo 'realpath(../..): ', realpath('../..'), "<br />\n";
- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
I tried out your code and nothing returned what I'm looking for, but great information... I can use it for something else. 
I think this will work:
I think this will work:
Code: Select all
$folders = $_SERVER['DOCUMENT_ROOT'];
$p_folders = explode('/',$folders);
$c_folders = count($folders);
$folders = explode('/',$folders,($c_folders-2));
$folders = implode('/',$folders);
echo $folders;