Overtrue\Validation\Validator::validateMimes PHP Method

validateMimes() protected method

Validate the MIME type of a file upload attribute is in a set of MIME types.
protected validateMimes ( string $attribute, array $value, array $parameters ) : boolean
$attribute string
$value array
$parameters array
return boolean
    protected function validateMimes($attribute, $value, $parameters)
    {
        if (!in_array($value, $_FILES, true)) {
            return false;
        }
        if (!empty($value['tmp_name']) && is_uploaded_file($value['tmp_name']) && $value['error']) {
            return false;
        }
        // The Symfony File class should do a decent job of guessing the extension
        // based on the true MIME type so we'll just loop through the array of
        // extensions and compare it to the guessed extension of the files.
        if ($value['tmp_name'] !== '') {
            return in_array(pathinfo($value['name'], PATHINFO_EXTENSION), $parameters, true);
        } else {
            return false;
        }
    }
Validator