I want to create a directory on windows from a PHP script.
My script is in the www/Test
directory of Apache and I want to create a folder (fold1) inside www/downloads
directory.
Inside the script, I'm using:
$dirName = "../downloads/fold1";
mkdir("{$dirName}");
If I use the full path of dirName like C:\Apache\www\downloads\fold1
, it works fine.
But I want to use a relative path since this code will be sent to the client.
I would guess your current directory is different from your files folder, so you have to use a trick:
mkdir(dirname(__FILE__) . "/" . $relative_path);
dirname(__FILE___)
returns the absolute path of your current php file. With this you can build an absolut path.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With