I actually tried to implement this feature but req.files and req.file are showing up undefined every time.
what i did actually is implemented a button on which whenever we click,a new input file field will be created and gets clicked automatically so that we could select files.In addition I also had created an anchor tag via which i will be passing the field names(file1,file2 etc) to the multer.Now when we click on the submit button,two events will happen in sequence,first of all the fieldname will be appended to the href of the anchor tag and gets clicked automatically and after that the form gets submitted.
Now on backend side the controller for that anchor tag create a new array (say ‘arr’) and pass it inside the
multer({storage:storage}).fields(arr) and saving this middleware in some variable say ‘mul’.Now the form submission takes place and its controller will be using the multer middleware which was present
inside the variable ‘mul’,but here req. files and req.file is showing up undefined.