hook_file_move
function hook_file_move
hook_file_move($file, $source)
Respond to a file that has been moved.
Parameters
$file: The updated file object after the move.
$source: The original file object before the move.
See also
Related topics
File
- modules/system/system.api.php, line 2949
- Hooks provided by Drupal core and the System module.
Code
function hook_file_move($file, $source) { $file_user = user_load($file->uid); // Make sure that the file name starts with the owner's user name. if (strpos($file->filename, $file_user->name) !== 0) { $file->filename = $file_user->name . '_' . $file->filename; $file->save(); watchdog('file', t('Moved file %source has been renamed to %destination', array('%source' => $source->filename, '%destination' => $file->filename))); } }
© 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_move/7.x