Description
Hey,
I need to upload multiple files to my node.js server but when i run
reqwest({ url: url, method: "POST", contentType: "multipart/form-data", data: data, headers: headers })
.
It fails to send files to my nodejs API.
Node.JS API
`router.post('/upload', upload.fields([
{ name: 'avatar', maxCount: 1 },
{ name: 'gallery', maxCount: 8 }
]), function(req, res, next) {
res.status(200);
res.send('Successfully uploaded ' + req.files.length + ' files!')
})
I even tried specifying boundry but that even didn't worked
But when i tried with jquery it worked
`
var form = new FormData();
form.append("avatar", "roku project (1).docx");
form.append("asdasd", "asdasd");
form.append("asdasd", "asdasd");
var settings = {
"async": true,
"crossDomain": true,
"url": "http://localhost:3000/v1/users/upload",
"method": "POST",
"headers": {
"cache-control": "no-cache",
"postman-token": "78a9f343-6b45-82ba-4850-57b6beeed937"
},
"processData": false,
"contentType": false,
"mimeType": "multipart/form-data",
"data": form
}
$.ajax(settings).done(function (response) {
console.log(response);
});
`