Sunday, May 19, 2013

[PHP][Apache][Sharing] How to look for your server path if $_SERVER['DOCUMENT_ROOT'] not work.

What you need:
-          FTP software (with permission to write)

If your administrator or hosting don’t tell you the server path,
How can you get that yourself?

The most common way is to using $_SERVER['DOCUMENT_ROOT'];

<?php echo $_SERVER['DOCUMENT_ROOT']; ?>


And then upload to the folder which u would like to know the path:


Visit the webpage and you would find the server_path of your php file was printed at the screen


For my case, It’s a bit special, the administrators has set the path setting in http.conf and caused ‘$_SERVER['DOCUMENT_ROOT'];’ can’t work correctly.
(p.s If I used that incorrect path by $_SERVER['DOCUMENT_ROOT'] function, I got this php error msg)


Similar topic:

My solution is quick tricky, is upload a php file with error and get the server path from the error msg. How to do that ?
1) Let create a php file named get_path.php
Place this line inside the file:

<?phpecho phpinfo1();?>
 2) Upload to directory where you would like to know the server path:


3) Visit the webpage and get the error msg:


For this case, the real path from the error message is :

/export/d08/test/slider/get_path.php 

No comments :

Post a Comment