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?
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");
}
});