I have a function
function fileFilter(req, file, cb) {
if (file.mimetype !== 'image/png' && file.mimetype !== 'image/jpg' && file.mimetype !== 'image/gif' ) {
console.log('Wrong format!');
return cb(null, false);
}
if ( file.size > 10000 ){
console.log('Image is too big!');
return cb(null, false);
}
cb(null, true);
}
var upload = multer({ storage: storage, fileFilter: fileFilter });
This function works when I am making post request.
router.post('/changeAvatar', upload.single('avatar'), function(req, res) {
var id = req.user._id;
res.redirect('/user/'+id);
});
How can I put flash connect-flash instead my console.log's? Connect-flash is already installed, with cockies and sessions. I tried different ways, but I can't understand phylosophy of flash messages...
via Bim Bam