Created
January 31, 2015 06:27
-
-
Save johnbocook/597d52417702d1104329 to your computer and use it in GitHub Desktop.
Rename Files on Upload in Drupal 7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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