mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
[ticket/10963] filespec::get_mimetype now used
filespec::get_mimetype now uses the finfo class in order to detect the mimetype of a given filename. filespec::is_image() now uses this method. PHPBB3-10963
This commit is contained in:
parent
f208b59c59
commit
4fbcf4eaad
1 changed files with 4 additions and 11 deletions
|
@ -151,9 +151,7 @@ class filespec
|
||||||
*/
|
*/
|
||||||
function is_image()
|
function is_image()
|
||||||
{
|
{
|
||||||
$finfo = new finfo(FILEINFO_MIME_TYPE);
|
$mimetype = $this->get_mimetype($this->filename);
|
||||||
$mimetype = $finfo->file($this->filename);
|
|
||||||
|
|
||||||
return (strpos($mimetype, 'image/') === 0);
|
return (strpos($mimetype, 'image/') === 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,17 +201,12 @@ class filespec
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get mimetype. Utilize mime_content_type if the function exist.
|
* Get mimetype. Utilises the finfo class.
|
||||||
* Not used at the moment...
|
|
||||||
*/
|
*/
|
||||||
function get_mimetype($filename)
|
function get_mimetype($filename)
|
||||||
{
|
{
|
||||||
$mimetype = '';
|
$finfo = new finfo(FILEINFO_MIME_TYPE);
|
||||||
|
$mimetype = $finfo->file($filename);
|
||||||
if (function_exists('mime_content_type'))
|
|
||||||
{
|
|
||||||
$mimetype = mime_content_type($filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Some browsers choke on a mimetype of application/octet-stream
|
// Some browsers choke on a mimetype of application/octet-stream
|
||||||
if (!$mimetype || $mimetype == 'application/octet-stream')
|
if (!$mimetype || $mimetype == 'application/octet-stream')
|
||||||
|
|
Loading…
Add table
Reference in a new issue