Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP display current server path

Tags:

php

I need to setup a path in my php but I currently don't know the path.

I need to configure the paths to the uploads directory

Should look like this below:

/srv/www/uploads/ 

My uploads.php file is in the root...so

www/uploads/ ??? 

Is there anyway that I could get php to tell me my current path?

like image 278
Satch3000 Avatar asked Sep 03 '12 16:09

Satch3000


People also ask

What is __ DIR __ in PHP?

The __DIR__ can be used to obtain the current code working directory. It has been introduced in PHP beginning from version 5.3. It is similar to using dirname(__FILE__). Usually, it is used to include other files that is present in an included file. Consider the following directory structure −

What is dirname (__ FILE __) in PHP?

dirname(__FILE__) allows you to get an absolute path (and thus avoid an include path search) without relying on the working directory being the directory in which bootstrap. php resides. (Note: since PHP 5.3, you can use __DIR__ in place of dirname(__FILE__) .)

What is server folder path?

Server path, absolute path and webroot are all different names for the same thing a path which defines where your files are located on the server.


1 Answers

If you call getcwd it should give you the path:

<?php   echo getcwd(); ?> 
like image 186
Nick Avatar answered Sep 25 '22 05:09

Nick