I try to upload several files at once using the Play Framework, but I always get the first image for each uploaded. Here's a specific case:
HTML:
<form method="post" action="/upload" enctype="multipart/form-data"> <input type="file" name="image" /> <input type="file" name="image" /> <input type="file" name="image" /> <input type="file" name="image" /> <input type="submit" name="submit" value="Send images" /> </form>
Controller:
public static void upload() { File[] images = params.get("image", File[].class); for (File f : images) { Logger.info (f.getName()); } }
If I download image1.jpg, image2.jpg, image3.jpg and image4.jpg, Logger.info the console will display:
image1.jpg image1.jpg image1.jpg image1.jpg
Other images will not be used.
I tried using List<File> instead of File[] , but it does not work.
I also saw that there is the same question about SO ( here ) that use this as an answer:
List<Upload> files = (List<Upload>) request.args.get("__UPLOADS");
But this does not work in v1.2.4 game !.
I am using Play v1.2.4.
Thank you very much for your help!
source share