function hook_file_presave

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

File

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

Code

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

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_file_presave/7.x