0

I have the following line of code which works on my local machine because the root directory of the server is the same as the root directory of the site.

$directories = explode("/", str_replace($_SERVER['DOCUMENT_ROOT'] . "/", "",  getcwd()));

How can I adapt this to work on my remove server where the root directory is several levels below that of the site. I guess I need to only include the site directories rather than the server directories.

Tom
  • 12,776
  • 48
  • 145
  • 240

1 Answers1

0

My logic states you need to put your remote server address here:

$directories = explode("/here/", str_replace($_SERVER['DOCUMENT_ROOT'] . "/", "",  getcwd()));

If that doesn't work, check these threads out, I think your solution is in one of them

SO Thread: Root path doesn't work with php include

Tech-Recipes-Thread: PHP: determine the directory path of the server root

Community
  • 1
  • 1
David D.
  • 367
  • 2
  • 13