The best way to rename file is using https://www.drupal.org/project/filefield_paths module .
The File (Field) Paths module extends the default functionality of Drupal's core File module, Image module and many other File upload modules, by adding the ability to use entity based tokens in destination paths and file names.
In simple terms, File (Field) Paths allows you to automatically sort and rename your uploaded files using token based replacement patterns to maintain a nice clean filesystem.
also you can rename it programmatically with hook_file_insert
something like
function hook_file_insert($file) { $parts = pathinfo($file->filename); if (in_array(mb_strtolower($parts['extension']), array('jpg', 'jpeg', 'gif', 'png', 'tif', 'flv', 'pdf'))) { $uri = 'public://' . 'dsfr_' . $file->uid . '_' . $file->timestamp . '.' . $parts['extension']; $file = file_move($file, $uri); } }