1 file.file.inc file_file_insert($file)

Implements hook_file_insert().

File

core/modules/file/file.file.inc, line 39
File hooks implemented by the Fil module.

Code

function file_file_insert($file) {
  // Save file metadata.
  if (!empty($file->metadata)) {
    $query = db_insert('file_metadata')->fields(array('fid', 'name', 'value'));
    foreach ($file->metadata as $name => $value) {
      $query->values(array(
        'fid' => $file->fid,
        'name' => $name,
        'value' => serialize($value),
      ));
    }
    $query->execute();
  }

  // Clear any related field caches.
  file_invalidate_field_caches($file);
}