Friday, November 2, 2012

Find the absolute path directoryof a server (php)

When you are dealing with CMS, sometimes you need the absolute path of a server. I need it for my opencart CMS, but in servers its hard to find out how?. Here is a php script which tells you the absolute path of directory where you are. Simplely upload this code on the desired directory and run, the script will tell you the absolute path.

<?php

$dir = dirname(__FILE__);

echo "<p>Full path to this dir: " . $dir . "</p>";

echo "<p>Full path to a .htpasswd file in this dir: " . $dir . "/.htpasswd" . "</p>";

?>



Lets try to be more precise:

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