Answers for "Upload different files in different folders using Multer in NodeJs"

0

Upload different files in different folders using Multer in NodeJs

const multer = require('multer')const storage = multer.diskStorage({destination: (req, file, cb) => {  const { userId } = req.body  const dir = ./uploads/${userId}  fs.exists(dir, exist => {  if (!exist) {    return fs.mkdir(dir, error => cb(error, dir))  }  return cb(null, dir)  })},filename: (req, file, cb) => {  const { userId } = req.body  cb(null, UserId-${userId}-Image-${Date.now()}.png)}})const upload = multer({ storage })
Posted by: Guest on October-25-2021

Code answers related to "Upload different files in different folders using Multer in NodeJs"

Code answers related to "Javascript"

Browse Popular Code Answers by Language