steviez Posted December 26, 2007 Share Posted December 26, 2007 Hi, I am working on a new scrpt, the problem im having is when i include a file (eg: <?php include("../includes/l.php"); ?>) even though its on the server it cant be found. Whats the best way to include a file so it can be found no matter what folder its in? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/83228-solved-file-paths/ Share on other sites More sharing options...
rajivgonsalves Posted December 26, 2007 Share Posted December 26, 2007 you should give something like <?php include($_SERVER['DOCUMENT_ROOT']."/includes/l.php"); ?> so it would be the absolute path... hope its helpfull Quote Link to comment https://forums.phpfreaks.com/topic/83228-solved-file-paths/#findComment-423376 Share on other sites More sharing options...
steviez Posted December 26, 2007 Author Share Posted December 26, 2007 Thanks for your reply what if your doc root is a sub folder like yourdomain.com/folder/folder2/ Thanks Quote Link to comment https://forums.phpfreaks.com/topic/83228-solved-file-paths/#findComment-423378 Share on other sites More sharing options...
rajivgonsalves Posted December 26, 2007 Share Posted December 26, 2007 are you trying to include a file above the doc root folder ? ... some servers do not allow it... Quote Link to comment https://forums.phpfreaks.com/topic/83228-solved-file-paths/#findComment-423385 Share on other sites More sharing options...
steviez Posted December 26, 2007 Author Share Posted December 26, 2007 My root folder is: /var/www/html/ Buy my script is running in: /var/www/html/projects/filehost/ I need to include files from the includes folder located in my script path I have tryed this: include(dirname(__FILE__) . '/includes/config.php'); but this gives me: /var/www/html/projects/filehost/admin/includes/config.php and i need: /var/www/html/projects/filehost/includes/config.php Thanks Quote Link to comment https://forums.phpfreaks.com/topic/83228-solved-file-paths/#findComment-423391 Share on other sites More sharing options...
steviez Posted December 26, 2007 Author Share Posted December 26, 2007 Any ideas on this? im desperate to get it sorted Quote Link to comment https://forums.phpfreaks.com/topic/83228-solved-file-paths/#findComment-423523 Share on other sites More sharing options...
revraz Posted December 26, 2007 Share Posted December 26, 2007 If its in the same folder, than just do include ("name.php"); If its in projects/filehost/includes then use include ("includes/name.php"); Quote Link to comment https://forums.phpfreaks.com/topic/83228-solved-file-paths/#findComment-423530 Share on other sites More sharing options...
steviez Posted December 26, 2007 Author Share Posted December 26, 2007 my file is in /projects/filehost/admin/ but the included file is in /projects/filehost/includes/ Quote Link to comment https://forums.phpfreaks.com/topic/83228-solved-file-paths/#findComment-423532 Share on other sites More sharing options...
revraz Posted December 26, 2007 Share Posted December 26, 2007 include ("../includes/name.php"); should work as you first stated. You can also do include ("www.mydomain.com/projects/filehost/includes/name.php"); Post the include error you get when you use the first path. Quote Link to comment https://forums.phpfreaks.com/topic/83228-solved-file-paths/#findComment-423540 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.