How can I upload multiple files with drupal 7?

大兔子大兔子 提交于 2020-01-01 19:18:36

问题


I'm making a drupal 7 module that contains a form and I would like to upload multiple files in a row. Currently I'm using a managed_file type of input field.

$form['attachment'] = array(
                            '#title' => t('Attachment'),
                            '#type' => 'managed_file',
                            '#default_value' => variable_get('attachment', ''),
                          '#upload_location' => 'public://perm/',
                            );

This gives me the upload button, but only lets me upload one file. Is there a way I can tell this form to upload a file and still keep the option for a second upload open?


回答1:


check out the new ajax system, it's pretty easy to implement, it should allow you to trigger an ajax callback once the file has been selected to add additional file fields to the form dynamically, just google "drupal 7 ajax" and you'll find dozens of examples




回答2:


have you checked to see if this is what you need? http://drupal.org/project/multiupload_filefield_widget



来源:https://stackoverflow.com/questions/5808207/how-can-i-upload-multiple-files-with-drupal-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!