I use the 'multer' plugin to upload files. I want to call another function after a successful file upload.
Here is my code:
module.exports.uploadFile = upload.single('file', '_id'), function (req, res, next) {
console.log('Uploade Successful');
}
var upload = multer({
storage: multer.diskStorage({
destination: './Media/ChatDocUpload',
filename: function (req, file, cb) {
var dest = './Media/ChatDocUpload';
var _chatMessageID = req.query.chatMessageID;
var _ext = file.originalname.substring(file.originalname.indexOf("."));
var _fileName = _chatMessageID + _ext;
cb(null, _fileName);
}
})
});
I want to call my new function after loading the image. Using this code, I can load the image successfully, but not get the callback function.
I need to call a new function after image upload is complete.
var uploadSuccessFn = function () {
}
source
share