function hook_file_insert


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 system.api.php hook_file_insert($file)
cle7 system.api.php hook_file_insert($file)
elmsmedia7 system.api.php hook_file_insert($file)
icor7 system.api.php hook_file_insert($file)
meedjum_blog7 system.api.php hook_file_insert($file)
mooc7 system.api.php hook_file_insert($file)

Respond to a file being added.

This hook is called after a file has been added to the database. The hook doesn't distinguish between files created as a result of a copy or those created by an upload.


$file: The file that has been added.

See also


Related topics

6 functions implement hook_file_insert()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

entity_crud_hook_test_file_insert in modules/simpletest/tests/entity_crud_hook_test.module
Implements hook_file_insert().
file_entity_file_insert in sites/all/modules/ulmus/file_entity/
Implements hook_file_insert().
file_test_file_insert in modules/simpletest/tests/file_test.module
Implements hook_file_insert().
imagefield_focus_file_insert in sites/all/modules/ulmus/imagefield_focus/imagefield_focus.module
Implementation of hook_file_insert().
pathauto_file_insert in sites/all/modules/ulmus/file_entity/file_entity.module
Implements hook_file_insert() on behalf of pathauto.module.

... See full list

1 invocation of hook_file_insert()
file_save in includes/
Saves a file object to the database.


modules/system/system.api.php, line 2818
Hooks provided by Drupal core and the System module.


function hook_file_insert($file) {
  // Add a message to the log, if the file is a jpg
  $validate = file_validate_extensions($file, 'jpg');
  if (empty($validate)) {
    watchdog('file', 'A jpg has been added.');



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.