How to create a directory/folder by php?
When I 开发者_JAVA技巧create a category in my CMS, I want to create its directory/folder in an image directory.
Can I create a directory or folder with php?
Can anyone tell me how please?
You want mkdir
:
mkdir("/path/to/my/dir");
or
mkdir("/path/to/my/dir", 0700);
If you want it to be private to the user creating it.
mkdir
Small change addition
if (is_dir("/path/to/my/dir") == false) {
/* 700 -> permissions , true -> recursive*/
if (mkdir("/path/to/my/dir",700,true) == false) {
/* your error handling */
}
}
精彩评论