Search code examples
javascriptnode.jsexpressfile-uploadmulter

What error will I get when I try to pass an empty field in multer


I want to check if the image field given to Multer will contain the file or not.

Multer does not throwing any error and server is just processing


Solution

  • You can change that in the endpoint handler.

    router.post('/upload-image', multer.single('file'), async (req, res) => {
    
      if(!req.file) {
        console.log('File is not uploaded');
      } 
    
    });