I use Multer for uploading file or images. Problem is that it is impossible to validate the real file extension.
Example: If someone rename filename.exe to filename.png, then it is still validate to upload.
Can you suggest me the solution to handle this issue? Thanks
I used like this but need verify real ext of files
fileFilter: async function (req, file, callback) {
var ext = path.extname(file.originalname);
if(ext !== '.png' && ext !== '.jpg' && ext !== '.gif' && ext !== '.jpeg' && ext !== '.zip') {
return callback(new Error('Only images and zip are allowed'));
}
// I want next function to validate real ext of files here.
callback(null, true);
},