I do not know what is going on here. Every time I try to upload a file, the whole file contains:
------WebKitFormBoundaryJ0uWMNv89fcUsC1t--
I have been looking for the last 2 days for some kind of explanation, but I'm just going in circles. I have no idea why this is happening.
The form:
<form id="upload-file" ecntype="multipart/form-data"> <input name="picture" type="file"> <input type="button" value="Upload" id="upload-button" /> </form>
JavaScript:
$('#upload-button').click(function(e){ e.preventDefault(); var formData = new FormData($('#upload-file')); $.ajax({ url: '/image', type: 'POST', xhr: function() { var myXhr = $.ajaxSettings.xhr(); if(myXhr.upload){ myXhr.upload.addEventListener('progress',progressHandlingFunction, false); } return myXhr; }, data: formData, cache: false,
Controller:
def image = Action(parse.temporaryFile) { request => request.body.moveTo(new File("/tmp/picture")) Ok("File uploaded") }
bad at scala
source share