cx42net
unread,Jan 17, 2012, 6:50:50 AM1/17/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to play-framework
I'm trying to upload multiple files at once with Play Framework, but I
always get the first image for each uploaded. Here's a concrete case :
The HTML :
[code]
<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>
[/code]
The controller :
[code]
public static void upload() {
File[] images = params.get("image", File[].class);
for (File f : images) {
Logger.info (f.getName());
}
}
[/code]
If I upload image1.jpg, image2.jpg, image3.jpg & image4.jpg, the
Logger.info on the console will display :
* image1.jpg
* image1.jpg
* image1.jpg
* image1.jpg
The other images won't be used.
I tried with List<File> instead of File[] but it doesn't work neither.
I also tried to put the File[] image directly in the method, doesn't
work neither.
I also saw on StackOverflow an alternative :
[code]
List<Upload> files = (List<Upload>) request.args.get("__UPLOADS");
[/code]
But it doesn't work in the v1.2.4 of Play!.
Thank you really much for your help