title: How to validate file extension with Multer middleware
body: <p>I use Multer for uploading file or images. Problem is that it is impossible to validate the real file extension.</p>
  
  <p>Example: If someone rename <code>filename.exe</code> to <code>filename.png</code>, then it is still validate to upload.</p>
  
  <p>Can you suggest me the solution to handle this issue? Thanks</p>
  
  <p>I used like this but need verify real ext of files</p>
  
  <pre><code>fileFilter: async function (req, file, callback) {
      var ext = path.extname(file.originalname);
      if(ext !== '.png' &amp;&amp; ext !== '.jpg' &amp;&amp; ext !== '.gif' &amp;&amp; ext !== '.jpeg' &amp;&amp; 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); 
    },
  </code></pre>