I\'m new to Node.js and I ran into a simple problem lately.
I\'m using multer
module to upload images.
In my web app all the users have a unique id, and I wa
you can solve this just referring to the input name and rename the path before assigning it.
app.use(multer({ dest: './standard_folder/',
rename: function (fieldname, filename) {
var pathHelper ='';
if(fieldname =='otherKindOfFolderNeeded'){
pathHelper = '../../path/to/other/folder/';
}
return pathHelper+uuid.v4()+Date.now();
},
onFileUploadStart: function (file) {
console.log(file.originalname + ' is starting ...')
},
onFileUploadComplete: function (file) {
console.log(file.fieldname + ' uploaded to ' + file.path)
done=true;
}
})
);