Relative path to windows php mkdir

I want to create a windows directory with a PHP script.

My script is in the www/TestApache directory , and I want to create a folder (fold1) inside the directory www/downloads.

Inside the script, I use:

$dirName = "../downloads/fold1";   
mkdir("{$dirName}");

If I use the full path to dirName as C:\Apache\www\downloads\fold1, it works fine.

But I want to use a relative path, as this code will be sent to the client.

+3
source share
1 answer

I would suggest that your current directory is different from your file folder, so you need to use the trick:

mkdir(dirname(__FILE__) . "/" . $relative_path);

dirname(__FILE___) php. .

+7

Source: https://habr.com/ru/post/1747504/


All Articles