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

php
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);
mkdir(path,mode,recursive,context)
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:

<?php 
if (!is_dir('path/to/directory')) 
// is_dir - tells whether the filename is a directory
{
    //mkdir - tells that need to create a directory
    mkdir('path/to/directory');
}
?>
See also  How to validate 'target=_blank' in anchor tag with W3C Compatibility