Haneef Puttur

HOW TO FIND THE FULL PATH TO A FILE USING PHP

HOW TO FIND THE FULL PATH TO A FILE USING PHP
Sometimes you need to know the full path to a file or directory, ie if you want to setup .htaccess authentication you need to enter the full path to the .htpasswd file. If you dont know the full path and PHP is installed on the server, you can get some help here.
Below is a small PHP script that prints the full path to the directory it is placed in. Copy the code and paste it into a file called fullpath.php. You can then upload the file to the directory where you want to place the .htpasswd. Then point your browser to http://www.your-domain.com/path/to/fullpath.php
$dir = dirname(__FILE__);
echo “

Full path to this dir: ” . $dir . “

“;

echo “

Full path to a .htpasswd file in this dir: ” . $dir . “/.htpasswd” . “

“;

?>

Haneef Puttur

***************
# Knowledge is like Water, Let it FLOW.. Don’t let it Rotten somewhere.. 

.