Add a test for unknow mimetype and use finfo_file in this case. Inspired by At_Libitum. re #72

This commit is contained in:
Sébastien Lucas 2013-12-31 11:12:34 +01:00
parent 6717d92a97
commit b4d3fe6b22
2 changed files with 35 additions and 2 deletions

View file

@ -64,11 +64,21 @@ class Data extends Base {
}
public function getMimeType () {
$result = "application/octet-stream";
if ($this->isKnownType ()) {
return self::$mimetypes [$this->extension];
} else {
return "application/octet-stream";
} elseif (function_exists('finfo_open') === true) {
$finfo = finfo_open(FILEINFO_MIME_TYPE);
if (is_resource($finfo) === true)
{
$result = finfo_file($finfo, $this->getLocalPath ());
}
finfo_close($finfo);
}
return $result;
}
public function getFilename () {