Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Unable to send multipart/form-data request #264

Open
@manishchauhanquovantis

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);
});
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /