checking file size before uploading image using multer

how can I use the submiting data related to image pass to server using multer before uploading it to disk .Is it possible ? if not then please give me another solution.
I want to check the size of file its should be at least 4mp resolution ,if its has lesser then that the images should not be uploaded and send the error msg

exports.uploadimg=(req,res,next)=>{
  
    uploadphoto(req, res, (err) => {
        if (err) {
            res.render("upload")
        }
        else {


    
            

          


           
            res.send("photo uloaded")
        }
    })