Example #1
0
 /**
  * Tries to detect the mime type of the given file.
  *
  * @param string $fpath Path to the local file
  *
  * @return string
  */
 protected static function detectMimetype($fpath)
 {
     // try to detect the file content type
     if (function_exists('finfo_open')) {
         if (self::$_infodb === null) {
             self::$_infodb = @finfo_open(FILEINFO_MIME);
         }
         if (self::$_infodb) {
             $mime = finfo_file(self::$_infodb, $fpath);
         }
     } else {
         $mime = mime_content_type($fpath);
     }
     if (!$mime) {
         $mime = 'application/octet-stream';
     }
     return $mime;
 }