allin44 Posted July 23, 2009 Share Posted July 23, 2009 Ok, I am getting tired of trying to figure out if its "../../file.php" or "../file.php" etc and I have several different folders, is there way so that it would automatically take the link back to the root directory of just / and then i could just point it to the proper folder from there? IE point it back to the root index so I could just code it as "Folder/file.php" as opposed to having a file in the Folder2 folder and having to do the "../Folder/file.php" Link to comment https://forums.phpfreaks.com/topic/167075-automatically-set-a-link-to-the-root-directory/ Share on other sites More sharing options...
xtopolis Posted July 23, 2009 Share Posted July 23, 2009 I believe you can set this with php.ini (link) I'm just not sure which thing to set ... I'm thinking it's include_path though Link to comment https://forums.phpfreaks.com/topic/167075-automatically-set-a-link-to-the-root-directory/#findComment-880942 Share on other sites More sharing options...
chronister Posted July 23, 2009 Share Posted July 23, 2009 I HATED this problem when I ran across it.... do this and save yourself the trouble.... include($_SERVER['DOCUMENT_ROOT'].'/path/to/file/from/root/directory'); This sort of equates to the html <img src="/start/at/root" > type syntax. When using $_SERVER['DOCUMENT_ROOT'], you will force the script to begin at the root directory, so that no matter where you are calling this from you will find your desired file. Nate Link to comment https://forums.phpfreaks.com/topic/167075-automatically-set-a-link-to-the-root-directory/#findComment-880966 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.