I try to upload multiple files with one request. My code looks like the following:
I've found a hackish way.
You have to import play.data.Upload
or play.data.*
public static void overviewsubmit(File fake) {
List<Upload> files = (List<Upload>) request.args.get("__UPLOADS");
for(Upload file: files) {
Logger.info("Size = %d", file.getSize());
}
}
Without the File fake
argument the method will not handle multipart/form-data
and you'll get an empty request.args
array. If anyone knows the play/standard annotation for it, let me know :)
You can check this for other useful functions - http://www.playframework.org/documentation/api/1.2.3/play/data/FileUpload.html
Hope it'll solve your problem.
I had the same problem but with an input field for multiple itens.
<input type="file" multiple="multiple" name="file" >
The problem was solved using an array instead of a List, in the action parameters:
public static void overviewSubmit(File[] files){
System.out.println(files);
}