function drupal_chmod


Error message

User warning: The following module is missing from the file system: theme/theme. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1156 of /var/www/html/elmsln_community/
cis7 drupal_chmod($uri, $mode = NULL)
cle7 drupal_chmod($uri, $mode = NULL)
elmsmedia7 drupal_chmod($uri, $mode = NULL)
icor7 drupal_chmod($uri, $mode = NULL)
meedjum_blog7 drupal_chmod($uri, $mode = NULL)
mooc7 drupal_chmod($uri, $mode = NULL)

Sets 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.

PHP's chmod does not support stream wrappers so we use our wrapper implementation which interfaces with chmod() by default. Contrib wrappers may override this behavior in their implementations as needed.


$uri: A string containing a URI file, or directory path.

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

Return value

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

Related topics

12 calls to drupal_chmod()
backup_migrate_destination_files::_save_file in sites/all/modules/ulmus/backup_migrate/includes/
File save destination callback.
boost_mkdir in sites/all/modules/ulmus/boost/boost.module
Create a directory.
boost_write_file in sites/all/modules/ulmus/boost/boost.module
Write to a file. Ensures write is atomic via rename operation.
file_create_htaccess in includes/
Creates a .htaccess file in the given directory.
file_prepare_directory in includes/
Checks that the directory exists and is writable.

... See full list


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


function drupal_chmod($uri, $mode = NULL) {
  if (!isset($mode)) {
    if (is_dir($uri)) {
      $mode = variable_get('file_chmod_directory', 0775);
    else {
      $mode = variable_get('file_chmod_file', 0664);

  // If this URI is a stream, pass it off to the appropriate stream wrapper.
  // Otherwise, attempt PHP's chmod. This allows use of drupal_chmod even
  // for unmanaged files outside of the stream wrapper interface.
  if ($wrapper = file_stream_wrapper_get_instance_by_uri($uri)) {
    if ($wrapper->chmod($mode)) {
      return TRUE;
  else {
    if (@chmod($uri, $mode)) {
      return TRUE;

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



Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/ in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/
The website encountered an unexpected error. Please try again later.