Skip to content

Instantly share code, notes, and snippets.

@johnbocook
Created January 31, 2015 06:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnbocook/597d52417702d1104329 to your computer and use it in GitHub Desktop.
Save johnbocook/597d52417702d1104329 to your computer and use it in GitHub Desktop.
Rename Files on Upload in Drupal 7
/**
* Implements hook_file_insert().
*/
function MYMODULE_file_insert($file) {
$hash = 'public://' . md5($file->filename) . '.' . pathinfo($file->filename, PATHINFO_EXTENSION);
file_move($file, $hash, 'FILE_EXIST_REPLACE');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment