dingus Posted July 23, 2008 Share Posted July 23, 2008 hey just a quick question from me im wondering how i can get the web path of a file with php...... for example at "www.example.com/testscript/test.php" the first line is require_one("../config.php"); in config.php how can i detect that its web path is www.example.com/config.php? Link to comment https://forums.phpfreaks.com/topic/116128-web-accessable-directory-of-a-file/ Share on other sites More sharing options...
tibberous Posted July 23, 2008 Share Posted July 23, 2008 I'm pretty sure you can't, but you can guess at it based off of the REQUEST_URI. The problem is that a file doesn't have a web path, it has a directory path. If that happens to be in a local Apache is serving, then it will have a web path, but it might not have any and it might have several, when you consider vhosts and domain aliases and rewrite rules, ect. A good starting place might be this: print_r($_SERVER); Link to comment https://forums.phpfreaks.com/topic/116128-web-accessable-directory-of-a-file/#findComment-597183 Share on other sites More sharing options...
teng84 Posted July 23, 2008 Share Posted July 23, 2008 echo $_SERVER['DOCUMENT_ROOT']; is that what you mean? Link to comment https://forums.phpfreaks.com/topic/116128-web-accessable-directory-of-a-file/#findComment-597191 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.