Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 367
  • Last Modified:

php tell me directory

__DIR__
does not work

__FILE__
tells me filename

but I want the directory that I am in (minus filename)
0
rgb192
Asked:
rgb192
2 Solutions
 
DjRedCommented:
You have a few options on this one...

The first is if the code you are using IS in the directory of the file you are using then there is no need to list the directory.....


Example:
Say you are in the directory "html/www/testDIR/"
and you had a file in it: "html/www/testDIR/test.php"

then you can easily in that test.php file declare the file you need without the current directory like so:
$filename = "testfilename.php";

and that will be the same as: "html/www/testDIR/testfilename.php"

or use an alternative like so:

<?php
// current directory
echo getcwd();
?>

Open in new window

0
 
p_nutsCommented:
How about this

http://www.php.net/manual/en/function.pathinfo.php

$patharr = pathinfo(__FILE__);

Echo $patharr['dirname'];
0
 
rgb192Author Commented:
thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now