• Avail guidance to develop Drupal modules & Drupal themes
  • Share and get review of your code
  • Get Access to free CodeBooks and ThemeBooks
  • Drupal 5, 6 and 7 covered

Drupal file upload: file_save_upload

Printer-friendly versionSend to a DeveloperPDF version

Drupal's file_save_upload function saves an uploaded file to a new location as specified in the parameter of the function.

Syntax:
Drupal 5: file_save_upload($source, $dest = FALSE, $replace = FILE_EXISTS_RENAME)
Drupal 6: file_save_upload($source, $validators = array(), $dest = FALSE, $replace = FILE_EXISTS_RENAME)
Drupal 7: file_save_upload($source, $validators = array(), $destination = FALSE, $replace = FILE_EXISTS_RENAME)

  • $source: This will be the field name using which the file is being uploaded.
  • $validators: This is an associative array of callback functions which validate the uploaded file. The function names are keys and and values of the array will be any arguments to be passed to the function callback
  • $dest: The location where the file specified in $source should be copied to. If set to FALSE or not writable, temporary directory will be used to copy the file
  • $replace: This is a kind of flag which decides what to do when a file with same name is already there. Setting this value to FALSE will make sure that all the files will have unique names.
5
Your rating: None Average: 5 (2 votes)
Syndicate content

Recent comments