Add a test for unknow mimetype and use finfo_file in this case. Inspired by At_Libitum. re #72
This commit is contained in:
parent
6717d92a97
commit
b4d3fe6b22
2 changed files with 35 additions and 2 deletions
14
data.php
14
data.php
|
@ -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 () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue