开发者

How to create a directory/folder by php?

开发者 https://www.devze.com 2022-12-15 11:41 出处:网络
When I 开发者_JAVA技巧create a category in my CMS, I want to create its directory/folder in an image directory.

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 */
        }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消