0

I have a form with 2 input field with type file and with different name attr. I wanna send these files and store it on my db, on the backedn i am using multer.

Now here is my form

<form aciton="/uploadFile" method="post" enctype="multipart/form-data" >
     <input type="file" name="file1" required multiple />
     <input type="file" name="file2" required multiple />
     <input type="submit" value="Upload" />
</form>

On the backend this is my what i am doing

var storage = multer.diskStorage({

  destination:(req,file,cb)=>{
    cb(null,'./public/uploads');
  },

  filename:(req,file,cb)=>{
    cb(null,file.originalname+'-'+Date.now())
  }

})

enter image description here

The Problem is that if i name both input field same, then its working, otherwise its not working.

Bucky
  • 127
  • 3
  • 8
  • https://stackoverflow.com/questions/36096805/uploading-multiple-files-with-multer-but-from-different-fields – sourav satyam Jan 22 '21 at 07:04
  • 2
    Does this answer your question? [Uploading multiple files with multer, but from different fields?](https://stackoverflow.com/questions/36096805/uploading-multiple-files-with-multer-but-from-different-fields) – osama Jan 22 '21 at 07:08

0 Answers0