
 Morten Sigsgaard - 2012-03-29 11:58:42
The file extension can easily be 'tricked'; i gladly took your class into use but adjusted the $this->icons keys to resemble mime-types instead.
Then there are two variants available, one for windows host another for unix:
function get_file_type() {
  if(function_exists('shell_exec') === TRUE) {
    $dump = shell_exec(sprintf('file -bi %s', $this -> filename));
    $info = explode(';', $dump); // split has deprecated
    return $info[0];
  } else {
    $fo = finfo_open(FILEINFO_MIME);
    $info = finfo_file($fo, $this -> filename);
    finfo_close($fo);
    return $info;
  }
  return FALSE;
}