Comments (3)
yes tricky one this one. After reviewing the multer code I found that is uses [fieldname] as a key.
if you do something like
$.each($("#file_upload")[0].files, function(file) {
console.log(this);
uploadForm.append("file", this);
})
using jquery then all files get uploaded with the fieldname file and multer overwrites them.
if you update the code to
$.each($("#file_upload")[0].files, function(file) {
console.log(this);
uploadForm.append("file" + file, this);
})
then they get uploaded with field name file(n)
files:
{ file0:
{ fieldname: 'file0',
originalname: 'Malebg.png',
name: '669f68871da447e19ae4c3ce98055503.png',
encoding: '7bit',
mimetype: 'image/png',
path: 'uploads/669f68871da447e19ae4c3ce98055503.png',
extension: 'png' },
file1:
{ fieldname: 'file1',
originalname: 'Malebg.xcf',
name: 'cdb7a9f58b095a2716a0664049537ac9.xcf',
encoding: '7bit',
mimetype: 'image/x-xcf',
path: 'uploads/cdb7a9f58b095a2716a0664049537ac9.xcf',
extension: 'xcf' }
}
from multer.
that is an excellent and simple solution. thanks!
from multer.
I still feel we need a better solution.
Not providing all the data sent through input doesn't make sense
from multer.
Related Issues (20)
- Custom storage engine not working
- MulterError: Unexpected field when trying to use different storage configuration HOT 1
- Update Docs: Error: read ECONNRESET thrown during test using supertest, mocha but works fine while using postman. HOT 1
- Why does Multer does not release memory? HOT 1
- `preservePath` option not respected HOT 2
- This module only works with node 14 or LOWER HOT 40
- file.size undefined with multiple files HOT 2
- Request not finish when recieve an error HOT 11
- File upload middleware does not work when I chain it with other middlewares. I get req.file = undefined HOT 3
- bug: transfer-encoding HOT 3
- File type shows correct on the frontend but it changes to application/octet-stream on the backend HOT 1
- CVE-2022-24434: DoS affecting dicer (sub-dependency) HOT 3
- Requests made through pinia display 'MulterError: Unexpected field at wrappedFileFilter' HOT 2
- Publish version 1.4.5 HOT 1
- last filename is missing from `req.files` while use of 'fileds' middleware.
- Error: Route.post() requires a callback function but got a [object Object]
- multer fields array returned only first file HOT 4
- Folder cannot be deleted HOT 1
- Upload multiple files with multer? HOT 2
- I just can't figured whats wrong why my codes below. I try to upload multiple files.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from multer.