4

How do I rename the uploaded files for my module?

2 Answers 2

4

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

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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