Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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 })
Comment

PREVIOUS NEXT
Code Example
Javascript :: react native stylesheet shortcut 
Javascript :: jquery ajax refresh 
Javascript :: react-google-login 
Javascript :: prettier printWidth 
Javascript :: passing data between components in react js 
Javascript :: reactjs lifecycle class components 
Javascript :: loop react components 
Javascript :: convert date to ist format javascript 
Javascript :: install react-native-safe-area-context 
Javascript :: substr method 
Javascript :: detect if user is online react 
Javascript :: permutation and combination program in javascript 
Javascript :: express post 
Javascript :: sort list of objects by value node js 
Javascript :: add word in string in javascript 
Javascript :: array in javascript 
Javascript :: js tostring 
Javascript :: javscript rename property name 
Javascript :: Destructuring of object in ES6 
Javascript :: react file preview 
Javascript :: dart json serializable 
Javascript :: lodash remove not in array 
Javascript :: add two floating point numbers jquery 
Javascript :: javascript regex all matches match 
Javascript :: how to use post method in react 
Javascript :: string length js 
Javascript :: ajax django send array 
Javascript :: React social login button 
Javascript :: usestate hook callback 
Javascript :: how can i do metaname csrf token attrcontent in vanilla javascrip 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =