Prodigal Son Posted July 7, 2008 Share Posted July 7, 2008 Ok, bit of a newb question, but I always hear of people saying to place files above the public html or document root folder for sensitive files. So do I just do this: include('../' . $_SERVER['DOCUMENT_ROOT'] . '/something/file.php'); Or is there something else your supposed to do? Some say to never use ../ when including files so not sure. Thanks. Link to comment https://forums.phpfreaks.com/topic/113654-solved-simple-document-rootpublic-html-question/ Share on other sites More sharing options...
Prodigal Son Posted July 8, 2008 Author Share Posted July 8, 2008 I heard about basedir, but I looked up php.net and didn't find any matches. Link to comment https://forums.phpfreaks.com/topic/113654-solved-simple-document-rootpublic-html-question/#findComment-584480 Share on other sites More sharing options...
rhodesa Posted July 8, 2008 Share Posted July 8, 2008 if your file structure is like: / php/ something/ file.php include_file.php config.php web/ index.php page.php then on index.php and page.php, just use: include('../php/config.php'); and on something/file.php use: include('../../php/config.php'); BUT, if in config.php, you want to include include_file.php, you need to do something different. Since the Current Working Directory might web/ or it might be web/something/, a simple relative path won't work. So, to get the path relative to config.php use: include(dirname(__FILE__).'/include_file.php'); make sense? Link to comment https://forums.phpfreaks.com/topic/113654-solved-simple-document-rootpublic-html-question/#findComment-584486 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.