'text/plain' * @example PDF file -> 'application/pdf' * * @return string Mime type */ public function getMimeType() { $finfo = finfo_open(FILEINFO_MIME); $mimetype = finfo_file($finfo, $this->getRealPath()); finfo_close($finfo); if ($mimetype !== false) { $mimetype = preg_replace('/^(.+);.+$/', '\1', $mimetype); } else { $mimetype = 'application/octet-stream'; } return $mimetype; } }