Код: Выделить всё
['avatar', 'file', 'extensions' => 'jpg,jpeg,gif,png', 'maxSize' => 5242880],
Метод в yii\validators\FileValidator, отвечающий за проверку расширения, выглядит так:
Код: Выделить всё
protected function validateExtension($file)
{
$extension = mb_strtolower($file->extension, 'utf-8');
if ($this->checkExtensionByMimeType) {
$mimeType = FileHelper::getMimeType($file->tempName);
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;
}
Код: Выделить всё
object(yii\web\UploadedFile)[156]
public 'name' => string 'common.css' (length=10)
public 'tempName' => string 'D:\www\temp\php1A05.tmp' (length=23)
public 'type' => string 'text/css' (length=8)
public 'size' => int 19604
public 'error' => int 0