code: public static function getMimeType($filename = '')
      {
          $ext = strtolower(substr($filename, strrpos($filename, '.')));
          switch ($ext) {
              case '.jpeg': case '.jpg': $mimetype = 'image/jpeg'; break;
              case '.gif': $mimetype = 'image/gif'; break;
              case '.png': $mimetype = 'image/png'; break;
              case '.txt': $mimetype = 'text/plain'; break;
              case '.html': case '.htm': $mimetype = 'text/html'; break;
              case '.zip': $mimetype = 'application/x-zip-compressed'; break;
              default: $mimetype = 'application/octet-stream';
          }
          return $mimetype;
      }
docs: Search the MIME type of a file
  
  @param string $filename The filename to check
  @return string The associated MIME type