vue-dropzone
vue-dropzone copied to clipboard
MulterError: Unexpected field
I am using Vude-Dropzone + Express.js + Multer. No problem to upload single file, but for multiple file it give me error "MulterError: Unexpected field".
<vue-dropzone
ref="myVueDropzone"
id="customdropzone"
class="text-center"
:options="dropzoneOptions"
@vdropzone-success="successResponse"
></vue-dropzone>
data: function() {
return {
dropzoneOptions: {
url: "http://localhost:3000/api/upload_location/",
thumbnailWidth: 150,
maxFilesize: 499,
timeout: 9000,
parallelUploads: 5,
uploadMultiple: true,
paramName: function() { return 'file'; },
},
},
}
Codes in express.js & multer:
const uploadImg = multer({
storage: '/upload/',
.....
})
router.post('/uploadPhoto/:id', uploadImg.array('file', 10), Photo.uploadPhoto);
I've tried to change dropzoneOptions to
paramName: function() { return 'file'; },
paramName: file,
Change multer to:
router.post('/uploadPhoto/:id', uploadImg.array('file', 10), Photo.uploadPhoto);
router.post('/uploadPhoto/:id', uploadImg.fields([{ name: 'file', maxCount: 10 }]), Photo.uploadPhoto);
But, no one success.
Any ideas how to solve this problem ?
I have the same problem here but I am working with ReactJS, I already solved it before with a single upload but it's not working for the array. Any help is appreciated.
+1