drupal_chmod

  1. drupal
    1. drupal7
Versionen
drupal7 drupal_chmod($path, $mode = NULL)

Set the permissions on a file or directory.

This function will use the 'file_chmod_directory' and 'file_chmod_file' variables for the default modes for directories and uploaded/generated files. By default these will give everyone read access so that users accessing the files with a user account without the webserver group (e.g. via FTP) can read these files, and give group write permissions so webserver group members (e.g. a vhost account) can alter files uploaded and owned by the webserver.

Übergabeparameter

$path String containing the path to a file or directory.

$mode Integer value for the permissions. Consult PHP chmod() documentation for more information.

Rückgabewert

TRUE for success, FALSE in the event of an error.

Verwandte Themen

▾ 6 functions call drupal_chmod()

file_check_directory in includes/file.inc
Check that the directory exists and is writable.
file_save_upload in includes/file.inc
Saves a file upload to a new location.
file_unmanaged_copy in includes/file.inc
Copy a file to a new location without calling any hooks or making any changes to the database.
image_save in includes/image.inc
Close the image and save the changes to a file.
_color_render_images in modules/color/color.module
Render images that match a given palette.
_color_save_stylesheet in modules/color/color.module
Save the rewritten stylesheet to disk.

Code

includes/file.inc, line 1907

<?php
function drupal_chmod($path, $mode = NULL) {
  if (!isset($mode)) {
    if (is_dir($path)) {
      $mode = variable_get('file_chmod_directory', 0775);
    }
    else {
      $mode = variable_get('file_chmod_file', 0664);
    }
  }

  if (@chmod($path, $mode)) {
    return TRUE;
  }

  watchdog('file', 'The file permissions could not be set on %path.', array('%path' => $path), WATCHDOG_ERROR);
  return FALSE;
}
?>

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen