framework/validators/FileValidator.php
protected function validateExtension($file)
    {
        $extension = mb_strtolower($file->extension, 'UTF-8');

        if ($this->checkExtensionByMimeType) {
            $mimeType = FileHelper::getMimeType($file->tempName, null, false);
            if ($mimeType === null) {
                return false;
            }

            $extensionsByMimeType = FileHelper::getExtensionsByMimeType($mimeType);

            if (!in_array($extension, $extensionsByMimeType, true)) {
                return false;
            }
        }

        if (!in_array($extension, $this->extensions, true)) {
            return false;
        }

        return true;
    }
protected function validateExtension($file)
    {
        $extension = mb_strtolower($file->extension, 'UTF-8');

        if ($this->checkExtensionByMimeType) {
            $mimeType = FileHelper::getMimeType($file->tempName, null, false);
            if ($mimeType === null) {
                return false;
            }

            $extensionsByMimeType = FileHelper::getExtensionsByMimeType($mimeType);

            if (!in_array($extension, $extensionsByMimeType, true)) {
                return false;
            }
        }

        if (!in_array($extension, $this->extensions, true)) {
            return false;
        }

        return true;
    }
protected function validateExtension ( $ file ) { $ extension = mb_strtolower ( $ file -> extension , 'UTF-8' ) ; if ( $ this -> checkExtensionByMimeType ) { $ mimeType = FileHelper :: getMimeType ( $ file -> tempName , null , false ) ; if ( $ mimeType === null ) { return false ; } $ extensionsByMimeType = FileHelper :: getExtensionsByMimeType ( $ mimeType ) ; if ( ! in_array ( $ extension , $ extensionsByMimeType , true ) ) { return false ; } } if ( ! in_array ( $ extension , $ this -> extensions , true ) ) { return false ; } return true ; }
Checks if given uploaded file have correct type (extension) according current validator settings.
@param UploadedFile $file
@return bool
Checks if given uploaded file have correct type ( extension ) according current validator settings .