Upload multiple files with XMLHttpRequest to Express.js 3.5 Server Upload multiple files with XMLHttpRequest to Express.js 3.5 Server express express

Upload multiple files with XMLHttpRequest to Express.js 3.5 Server


Thx to @Pengtuzi I solved it:

I used the FormData API to upload the files. My mistake was that I thought the error would happen on the server.

Here's the code that solved it for me:

function uploadFiles(files) {    var xhr = new XMLHttpRequest();    var formData = new FormData();    xhr.onload = successfullyUploaded;    xhr.open("POST", "http://localhost:3000/upload", true);    xhr.setRequestHeader('X-Requested-With','XMLHttpRequest');    for(var file in files) {        formData.append("uploads", files[file].data);    }    xhr.send(formData);}