Alexey
Alexey

Reputation: 7247

How can i do multiple file upload using Drupal 7 Form API?

I'd like to upload multiple files using Form API.

'#type' => 'file' provides upload only one file.

$form['picture_upload'] = array( 
  '#type' => 'file', 
  '#title' => t(''), 
  '#size' => 50, 
  '#description' => t(''),
  '#weight' => 5,               
);

How can i provide multiple upload?

Upvotes: 8

Views: 7756

Answers (2)

Marius Ilie
Marius Ilie

Reputation: 3323

This is similar to a issue I had: Drupal 7 retain file upload

You can use managed_file element type instead of file

here's the drupal documentation: http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html/7#managed_file

Upvotes: 1

fmitchell
fmitchell

Reputation: 901

Aside from putting the form element in a for loop, I would suggest (for now) using the plupload form element.

http://drupal.org/project/plupload

Then:

$form['picture_upload'] = array( 
  '#type' => 'plupload', 
  '#title' => t(''), 
  '#size' => 50, 
  '#description' => t(''),
  '#weight' => 5,               
);

Upvotes: 4

Related Questions