title: Double extension will bypass extension check rules
body: <p>It is said in many article about securing file upload that it is better to prepare a white list of extension instead of a blacklist. But it seems this method has some problem with double extension files. For example I have a whitelist like 'pdf','doc','docx' but this white list return true for apple.php.doc or apple.doc.php .</p>
  
  <p>How can I write a secure extension check function?</p>