0

I am using express-fileupload as my middleware and POSTMAN as my API, how do I only upload jpg images and not others file extensions?

1 Answers1

0

You can check the mimetype and throw an error if it isn't .jpg

For example:

app.post('/upload', function(req, res) {
  if (req.files.image.mimetype !== "jpg") {
    throw new Error("Only supports jpg file format");
  }
});
Pasindu Dilshan
  • 366
  • 1
  • 15