file($file_src); $mime_types = mimeTypes(); // build the mime type according to the allowed extension. $check_type = []; foreach ($valid_ext as $ext) { $ext = strtolower(ltrim($ext, '.')); if (isset($mime_types[$ext])) { $check_type[$ext][] = $mime_types[$ext]; } } $check_ext = strtolower(ltrim($file_ext, '.')); if (!empty($check_type[$check_ext])) { if (is_array($check_type[$check_ext])) { if (self::in_array_r($type, $check_type[$check_ext])) { return TRUE; } } } return FALSE; } /* * Abort mimecheck because the webserver does not have this extension. */ return TRUE; } private static function in_array_r($needle, $haystack, $strict = FALSE) { foreach ($haystack as $item) { if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && self::in_array_r($needle, $item, $strict))) { return TRUE; } } return FALSE; } } require_once(__DIR__.'/../mimetypes_include.php');