I use multer to upload my images and documents, but this time I want to limit the download if the image size is> 2mb. How to find document file size? So far I have tried, as shown below, but have not worked.
var storage = multer.diskStorage({ destination: function (req, file, callback) { callback(null, common.upload.student); }, filename: function (req, file, callback) { console.log(file.size+'!!!!!!!!!!!!!!')======>'Undefined' var ext = ''; var name = ''; if (file.originalname) { var p = file.originalname.lastIndexOf('.'); ext = file.originalname.substring(p + 1); var firstName = file.originalname.substring(0, p + 1); name = Date.now() + '_' + firstName; name += ext; } var filename = file.originalname; uploadImage.push({ 'name': name }); callback(null, name); } });
Can anybody help me?
source share