Find a files server path when programming in PHP

If you ever need to find a files path when programming in PHP. All you need to do is drop the below code in a text file called path.php.

<?php $p = getcwd(); echo $p; ?>

Put it in the same directory as the file whose path you need and go to it in your web browser.

http://www._yourwebname_.com/_thedirectorythefileisin_/path.php

You will get back something like this.

C:\Websites\_yourwebname_\_thedirectorythefileisin_

So now you know the server path to the file you need.

Simple.

2 thoughts on “Find a files server path when programming in PHP

  1. Sean

    Cool. Thanks. I had actually been needing this for a while and just didn’t bother to google it.

Leave a Reply

Your email address will not be published. Required fields are marked *