harbingerkun Posted November 13, 2006 Share Posted November 13, 2006 Can anyone help me with this? I am trying to dynamically detect the path forincludes located outside the document root. The includes are stored in a foldercalled 'libs' one level above the document root as a means of security. Becauseof the nature of the application, using an absolute path such as '/var/www/libs/'is not an option. This path must be set dynamically. What is the best method toachieve this?Directory Structure:[tt] /var/ /lib/ include.php /www/ index.php[/tt] Link to comment https://forums.phpfreaks.com/topic/27053-how-to-detect-parent-directory-dynamically/ Share on other sites More sharing options...
Destruction Posted November 13, 2006 Share Posted November 13, 2006 If it's always the directory above the document root, and your document root is configured correctly, you should be able to do something similar to this...[code]<?php$includeDir = $_SERVER['DOCUMENT_ROOT']."/../";?>[/code]...which would find your document root, as configured by server, and go one level up. This would be the same in any file.HTHDest Link to comment https://forums.phpfreaks.com/topic/27053-how-to-detect-parent-directory-dynamically/#findComment-123736 Share on other sites More sharing options...
harbingerkun Posted November 13, 2006 Author Share Posted November 13, 2006 That is precisely what I needed. And to boot, I knew it would be something simple like this. Much appreciated! Link to comment https://forums.phpfreaks.com/topic/27053-how-to-detect-parent-directory-dynamically/#findComment-123741 Share on other sites More sharing options...
Destruction Posted November 13, 2006 Share Posted November 13, 2006 Forgot to make it ../lib/ but you get the idea and no worries, glad to have helped :)Dest Link to comment https://forums.phpfreaks.com/topic/27053-how-to-detect-parent-directory-dynamically/#findComment-123744 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.