On Tue, 24 Mar 2015 15:08:38 GMT, Henning Pohl wrote:
Hi there,
how to make file upload via jQuery AJAX work? I tried almost everything but I always get a 400 error. There is no example/documention on that topic available. This is my current guess:
var files = e.target.files; var data = new FormData(); data.append('upload', files[0]); $.ajax({ url: 'upload', type: 'POST', data: data, processData: false, contentType: 'multipart/form-data' });
Thank you
I haven't tried this before, so I can't say if it will actually work, but this StackOverflow answer suggests to set contentType
to false
to get the correct boundary string included.