Jump to content

Automatically set a link to the root directory


allin44

Recommended Posts

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"

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

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.