Cannot upload multiple files without "[]"
See original GitHub issueSummary
I tried to upload multiple files using requestjs but only the last file in the array was uploaded unless I added “[]” after the key.
Simplest Example to Reproduce
var formData = {
attachments: [
fs.createReadStream(__dirname + '/attachment1.jpg'),
fs.createReadStream(__dirname + '/attachment2.jpg')
]
};
request.post({url:'http://service.com/upload', formData: formData}, function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log('Upload successful! Server responded with:', body);
});
Expected Behavior
Server should receive two files.
Current Behavior
Only the last file in the array was uploaded.
Possible Solution
Now I could only change the key from “attachments” to “attachments[]” to avoid this problem. But I think this is a bug because the doc says it is ok to use “attachment” as the key to upload multiple files.
software | version |
---|---|
request | 2.81.0 |
node | 6.11.2 |
npm | 3.10.10 |
Operating System | macOS |
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:5
Top Results From Across the Web
"Upload Multiple Documents" is disabled in Document Library
Workaround. In the Document Library, under Library Tools click on Datasheet View, then click on Standard View. The Upload Multiple Documents command should...
Read more >Cannot upload multiple files - javascript - Stack Overflow
I have a small part of my app that allow users to upload 5 different images and as soon as an image has...
Read more >i cannot upload multiple files in web - Issues - GitLab
Hi all. i just started to try to use GITLAB and i just discovered you cannot upload multiple files in web i been...
Read more >Cannot upload multiple files to my website any more. Used to ...
Cannot upload multiple files to my website any more. Used to be able to, now it's one at a time. WHat happened? IE...
Read more >File Upload related list in console cannot upload multiple files ...
Currently it is not supported from the console view. Please log an idea for this. Thanks. Suman. Expand Post.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I ended up having to use the “advanced method” in https://github.com/request/request#forms.
Would be nice to just be able to pass an Array or something.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.