title: PHP finfo_file() shows incorrect MIME for JS files starting with comment
body: <p>I want to test my uploaded file whether it is a plain/text file or not. For this I'm using the following code:</p>
  
  <pre><code>private function isUploadedFileTextFile() {
      return finfo_file(
               finfo_open(FILEINFO_MIME_TYPE),
               $_FILES['file']['tmp_name']
             ) == 'text/plain';
  }
  </code></pre>
  
  <p>It was working in most of the cases but when I try to upload a js file which starts with comments (and the same with CSS) then it says it is plain/text and it lets my file to be uploaded.
  I've read about a bug in finfo_file ( <a href="https://bugs.php.net/bug.php?id=53035" rel="nofollow">https://bugs.php.net/bug.php?id=53035</a> ) and I've also heard that this finfo_open is not really reliable because it's trying to figure out the mime type based on the content, but I'm curious, what would you suggest to do in order to allow only plain/text files to be uploaded? (i.e. exclude these script files and stylesheets also)</p>
  
  <p>edit 1: Strange that the <code>$_FILES['file']['type']</code> shows correctly that it is <code>application/x-javascript</code> but I've heard I should not rely on this either. Or should I use double check?</p>
  
  <p>Thanks!</p>