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

2

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?

Veinlet answered 17/10, 2011 at 18:29 Comment(1)
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.Quark
A
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

Armindaarming answered 27/10, 2011 at 8:24 Comment(2)
Accepted answer? Why? This is not a solution for multiple file upload.Corkscrew
For Drupal 7, plupload module (mentioned in another answer on this page) seems to be the only way to do this.Pneumococcus
T
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,               
);
Trackandfield answered 25/10, 2011 at 20:21 Comment(0)
A
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

Armindaarming answered 27/10, 2011 at 8:24 Comment(2)
Accepted answer? Why? This is not a solution for multiple file upload.Corkscrew
For Drupal 7, plupload module (mentioned in another answer on this page) seems to be the only way to do this.Pneumococcus

© 2022 - 2024 — McMap. All rights reserved.