php mkdir windows relative path
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:
开发者_JS百科$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.
精彩评论