Autarchy of the Private Cave

Tiny bits of bioinformatics, [web-]programming etc

    • Archives

    • Recent comments

    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):

    1. <?php
    2. echo realpath(dirname(__FILE__));
    3. ?>

    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:

    1. <?php
    2. echo getcwd();
    3. ?>

    This also should display the absolute path on your server.


    17 Responses to “How to find absolute path on a web-server (using PHP)”

    1. Sabuj Kundu aka Manchumahara Says:

      Thanks. It works.

    2. Anup Says:

      Thanks a lot

    3. Francis Says:

      Oh Gosh,, I spent the whole day at work today trying to find this for my joomla site.. Really helpfull Thanks alot

    4. ASC Says:

      Simple and brilliant. Couldn’t have been easier. Thanks

    5. Gordy Chamberlain Says:

      Thank You! Saved my bacon as I had the wrong pathway.
      A big time saver for me.
      Onece again Thhhhhaaaanks

    6. Says:

      Worked perfectly for me — many thanks!

    7. PropaneFitness Says:

      Thanks, you’re a lifesaver!

    8. anonymous Says:

      Thanks alot.
      I was looking for this function for hours.

    9. Fuad Says:

      thanks this php path information was really helpful

    10. Thanks! Says:

      Thanks for the script, worked perfect!!!

    11. Andrés Says:

      Work perfect, thank you very much.

    12. vonbeau Says:

      Thank you, worked perfect for what I needed. :)

    13. Ronal Says:

      thanks a lot, for this. very helpful

    14. Come risolvere Ita: JFolder::create: Non ̬ stato possibile creare la cartella РEng: JFolder::create: Could not create directory | blog levelzero Says:

      [...] i permessi in 755 o 777, sempre in base al vostro web-server. Per ulteriori approfondimenti: This entry was posted on Saturday, March 23rd, 2013 at 7:42 pm and is filed under Front Page, [...]

    15. Chris Says:

      You are awesome! It worked perfectly.

    16. Arup Ghosh Says:

      Thnaks for the guide.

    17. rumah joglo Says:

      It works,Thanks you

    Leave a Reply

    XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>