* Etemplate - Don't trust browsers mime if we don't have to - fixes incorrect mime types and Resources rejecting pictures

This commit is contained in:
nathangray 2018-01-30 09:14:37 -07:00
parent 20cde78af3
commit 9a398594ac

View File

@ -147,10 +147,15 @@ class File extends Etemplate\Widget
}
if ($file['error'] == UPLOAD_ERR_OK && trim($file['name']) != '' && $file['size'] > 0 && is_uploaded_file($file['tmp_name'])) {
// Don't trust what the browser tells us for mime
if(function_exists('mime_content_type'))
{
$file['type'] = $type = mime_content_type($file['tmp_name']);
}
// Mime check
if($mime)
{
$type = $file['type'];
$is_preg = $mime[0] == '/';
if (!$is_preg && strcasecmp($mime,$type) ||
$is_preg && !preg_match($mime,$type))