8

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?

Clive
  • 36,918
  • 8
  • 87
  • 113
Alexey
  • 7,127
  • 9
  • 57
  • 94
  • I've been looking for a solution to this issue for days without luck... Unfortunately all the good batch uploaders from D6 were either using depreciated methods or simply not updated for D7. – Jane Panda Oct 23 '11 at 16:58

2 Answers2

4

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,               
);
fmitchell
  • 891
  • 1
  • 6
  • 7
1

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

Community
  • 1
  • 1
Marius Ilie
  • 3,283
  • 2
  • 25
  • 27