How to find absolute path on a web-server (using PHP)
30th April 2007
When using PHP, the simplest way to find the absolute path of your files/folders on the server is by creating a simple path.php file with the following contents (click on the “Plain text” box header for copy-pasting):
- <?php
- echo realpath(dirname(__FILE__));
- ?>
Put the new file anywhere in the web-accessible folder on your server,
then just access that file from your favourite web-browser – and you’ll have the absolute path shown to you.
Alternatively, you may use the following code:
- <?php
- echo getcwd();
- ?>
This also should display the absolute path on your server.
April 12th, 2009 at 22:15
Thanks. It works.
April 19th, 2009 at 16:50
Thanks a lot
May 22nd, 2010 at 1:41
Oh Gosh,, I spent the whole day at work today trying to find this for my joomla site.. Really helpfull Thanks alot
May 28th, 2010 at 1:18
Simple and brilliant. Couldn’t have been easier. Thanks
August 29th, 2010 at 6:07
Thank You! Saved my bacon as I had the wrong pathway.
A big time saver for me.
Onece again Thhhhhaaaanks
February 23rd, 2011 at 23:44
Worked perfectly for me — many thanks!
June 9th, 2011 at 1:02
Thanks, you’re a lifesaver!
July 20th, 2011 at 16:03
Thanks alot.
I was looking for this function for hours.
July 25th, 2011 at 4:34
thanks this php path information was really helpful
November 25th, 2011 at 6:00
Thanks for the script, worked perfect!!!
January 12th, 2012 at 19:13
Work perfect, thank you very much.
January 17th, 2012 at 4:28
Thank you, worked perfect for what I needed.
November 20th, 2012 at 18:58
thanks a lot, for this. very helpful
March 23rd, 2013 at 21:43
[...] i permessi in 755 o 777, sempre in base al vostro web-server. Per ulteriori approfondimenti: http://bogdan.org.ua/2007/04/30/how-to-find-absolute-path-on-a-web-server-using-php.html This entry was posted on Saturday, March 23rd, 2013 at 7:42 pm and is filed under Front Page, [...]
September 6th, 2014 at 19:34
You are awesome! It worked perfectly.
July 15th, 2015 at 17:59
Thnaks for the guide.
October 8th, 2015 at 6:38
It works,Thanks you