essjay_d12 Posted May 24, 2007 Share Posted May 24, 2007 Hi I am getting problems linking to files within different folders.... can some one explain the following ../ as i thought that should direct to the root folder I have root/admin/db/inc/file.php and am trying to link to the css in the following... in that file i want to require config.php which is located root/inc/config.php so i assumed (as i dont wish to put the full URL in - incase some other site wants to use the code) that you could do it like so... require("../inc/config.php"); But this is not working! Anybody got any solutions or explain further how ../ works?? thanks d Quote Link to comment https://forums.phpfreaks.com/topic/52786-requirefilephp-linking-problem/ Share on other sites More sharing options...
MadTechie Posted May 24, 2007 Share Posted May 24, 2007 ../ means backone then add a / so from root/admin/db/inc/file.php ../ is root/admin/db/file.php / = root (not home) Quote Link to comment https://forums.phpfreaks.com/topic/52786-requirefilephp-linking-problem/#findComment-260617 Share on other sites More sharing options...
448191 Posted May 24, 2007 Share Posted May 24, 2007 I can't make heads or tails of the full text above, but to answer the question of what "../" is: It's a link, meaning "one dir up". Actually only the the dots are the link. . "this dir" .. "one dir up" The first ("this dir") is added to the include path in default php.ini configuration, that is why you are able to omit paths when including files in the same directory. For relative HTTP links in HTML I recommend you make all links relative to the site root, example: "/img/pic.jpg", "/css/default.css". Quote Link to comment https://forums.phpfreaks.com/topic/52786-requirefilephp-linking-problem/#findComment-260618 Share on other sites More sharing options...
ToonMariner Posted May 24, 2007 Share Posted May 24, 2007 when ever I use include or require I start with $_SERVER['DOCUMENT_ROOT'] and specify a full path. So far it has helped prevent and malicious attacks on file includes when the include is dependant on user input..... Quote Link to comment https://forums.phpfreaks.com/topic/52786-requirefilephp-linking-problem/#findComment-260619 Share on other sites More sharing options...
448191 Posted May 24, 2007 Share Posted May 24, 2007 when ever I use include or require I start with $_SERVER['DOCUMENT_ROOT'] and specify a full path. So far it has helped prevent and malicious attacks on file includes when the include is dependant on user input..... Data in the $_SERVER array is not necessarily to be trusted. Better to manage include_path and utilize open_basedir. Quote Link to comment https://forums.phpfreaks.com/topic/52786-requirefilephp-linking-problem/#findComment-260622 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.