im using Java Play Framework and this File-Upload-Plugin: http://blueimp.github.io/jQuery-File-Upload/ . After read the documentation http://www.playframework.com/documentation/2.0/JavaFileUpload i used this specific code in my Java Play Controller.
public static Result upload() {
File file = request().body().asRaw().asFile();
return ok("File uploaded");
}
I've also added this route to my project:
POST /upload controllers.Image.upload()
My View-Template:
@(scripts: Html)
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>jQuery File Upload Example</title>
</head>
<body>
<input id="fileupload" type="file" name="files[]" data-url="/upload">
@scripts
<script>
$(function () {
$('#fileupload').fileupload({
dataType: 'json',
add: function (e, data) {
data.context = $('<p/>').text('Uploading...').appendTo(document.body);
data.submit();
},
done: function (e, data) {
data.context.text('Upload finished.');
}
});
});
</script>
</body>
Now if i upload a image firebug shows me the following error:
"NetworkError: 500 Internal Server Error - http://localhost:9000/upload"
The error was caused by this one line in the Controller Upload-action:
File file = request().body().asRaw().asFile();
Anyone know a solution? Thank you for your help.