Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 940
Alexey Avatar asked Oct 17 '11 18:10

Alexey


People also ask

How many methods are required minimum to create a form in Drupal?

Form API workflow is dependent on four main methods i.e. getFormId, buildForm, validateForm, and submitForm.


1 Answers

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,               
);
like image 90
fmitchell Avatar answered Sep 27 '22 17:09

fmitchell