How do I rename the uploaded files for my module?


You might find some information about how to code changing file names in the File (Field) Paths module.

$file = file_save_upload('file' , array(
  'file_validate_is_image' => array(), 
  'file_validate_extensions' => array('png gif jpg jpeg docx')

$file->filename = basename($file->uri);
if ($file) {
  if ($file = file_move($file, 'public://rohit')) {
    $form_state['storage']['file'] = $file;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.