hook_file_presave

  1. drupal
    1. 8
    2. 7
Versions
7 – 8 hook_file_presave($file)

Act on a file being inserted or updated.

This hook is called when 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.

Parameters

$file The file that has just been created.

See also

file_save()

Related topics

Code

modules/system/system.api.php, line 2626

<?php
function hook_file_presave($file) {
  // Change the file timestamp to an hour prior.
  $file->timestamp -= 3600;
}
?>