title: getimagesize() vs finfo_file() for detecting image type?
body: <p>Sometimes images don't have extensions, but are still valid. I have a file upload form and need to detect the filetype to compare it against my whitelist.</p>
  
  <p>I know I can't trust the mime type sent from the browser, so from the research I've done it looks like these are the two options available (they only work after uploading the file):</p>
  
  <pre><code>$info      = getimagesize($path);
  $imageType = $info['mime'];
  </code></pre>
  
  <p>And</p>
  
  <pre><code>$finfo     = finfo_open(FILEINFO_MIME_TYPE);
  $imageType = finfo_file($finfo, $path);
  </code></pre>
  
  <p>From the testing I've done, it looks like they both work just fine, but I'm wondering if there are any reasons to use one of these methods over the other?</p>