+91-943-185-6038 me@shashidharkumar.com

Create a folder if it doesn’t already exist in php
Defination and Usage:
The mkdir() function creates a directory.
This function returns TRUE on success, or FALSE on failure.

mkdir(‘path/to/directory’, 0755, true);
path – Required. Specifies the name of the directory to create
mode – Optional. Specifies permissions. By default, the mode is 0777 (widest possible access).
recursive – Optional. Specifies if the recursive mode is set (added in PHP 5)
context – Optional. Specifies the context of the file handle. Context is a set of options that can modify the behavior of a stream (added in PHP 5)

Note: The mode parameters is ignored on Windows platforms.

If you want to paas the permission to the category than following line be helpful:

if (!is_dir('path/to/directory')) 
// is_dir - tells whether the filename is a directory
    //mkdir - tells that need to create a directory
See also  Simple email script in php