vue-dropzone icon indicating copy to clipboard operation
vue-dropzone copied to clipboard

MulterError: Unexpected field

Open cakka-learn opened this issue 5 years ago • 2 comments

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 ?

cakka-learn avatar Nov 17 '20 10:11 cakka-learn

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.

SE-SalamAQuran avatar Apr 04 '21 12:04 SE-SalamAQuran

+1

alexdarh avatar Oct 05 '22 13:10 alexdarh