1.20.x system.api.php hook_file_presave(File $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 $file: The file entity that is about to be created or updated.

Related topics

File

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

Code

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