php make directory if not exists code example
Example 1: php mkdir if not exists
<?php
if (!file_exists('path/to/directory')) {
/**
* 0755 - Permission
* true - recursive?
*/
mkdir('path/to/directory', 0755, true);
}
Example 2: php mkdir
// Create a directory with the permission level (optional)
<?php
mkdir("/path/to/my/dir", 0700);
?>