shin
shin

Reputation: 32721

How to create a directory/folder by php?

When I 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?

Upvotes: 2

Views: 14161

Answers (3)

pradosh nair
pradosh nair

Reputation: 945

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

Upvotes: 0

YOU
YOU

Reputation: 123927

mkdir

Upvotes: 1

Brian Campbell
Brian Campbell

Reputation: 333294

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.

Upvotes: 11

Related Questions