function drupal_mkdir

7.x drupal_mkdir($uri, $mode = NULL, $recursive = FALSE, $context = NULL)

Creates a directory using Drupal's default mode.

PHP's mkdir() does not respect Drupal's default permissions mode. If a mode is not provided, this function will make sure that Drupal's is used.

Compatibility: normal paths and stream wrappers.


$uri: A URI or pathname.

$mode: By default the Drupal mode is used.

$recursive: Default to FALSE.

$context: Refer to

Return value

Boolean TRUE on success, or FALSE on failure.

See also


Related topics

7 calls to drupal_mkdir()
Archive_Tar::_dirCheck in drupal/modules/system/
Check if a directory exists and create it (including parent dirs) if not.
Archive_Tar::_extractList in drupal/modules/system/
drupal_install_mkdir in drupal/includes/
Creates a directory with the specified permissions.
FileTestCase::createDirectory in drupal/modules/simpletest/tests/file.test
Create a directory and assert it exists.
file_prepare_directory in drupal/includes/
Checks that the directory exists and is writable.

... See full list


drupal/includes/, line 2330
API for handling file uploads and server file management.


function drupal_mkdir($uri, $mode = NULL, $recursive = FALSE, $context = NULL) {
  if (!isset($mode)) {
    $mode = variable_get('file_chmod_directory', 0775);

  if (!isset($context)) {
    return mkdir($uri, $mode, $recursive);
  else {
    return mkdir($uri, $mode, $recursive, $context);