I'm working in a user interface in Java using GWT and I need to implement a component that allows the users to select multiple files and then upload all of them. I'm currently using UploadDialog from the package com.gwtextux.client.widgets.upload However I'm not able to add multiple files at once. It allows me to upload multiple files to the server but the users have to select the files one by one. Is there any way to allow the users to select multiple files using UploadDialog? is there any other alternative for this?
2 Answers
I recommend to use the gwtupload library. It allows you to select multiple files one-by-one, enqueue and send them showing a progress bar in any browser, but with the last version (0.6.7-SNAPSHOT) you can even select several files at once in the browser file dialog if you use a modern browser supporting the multiple attribute
Take a look to the gwtupload examples there are uploaders with the multiple option enabled and disabled.
1 Comment
Without the use of an additional library you can simply subclass FileUpload and add the multiple attribute:
public class MultiFileUpload extends FileUpload { @UiConstructor public MultiFileUpload() { this.getElement().setAttribute("multiple", "multiple"); } } // Then in uiBinder: <c:MultiFileUpload name="myFiles" /> Or just set the attribute on a regular FileUpload
@UiField FielUpload myUpload; .... myUpload.setAttribute("multiple", "multiple");