maxsize = $size; } function setType(array $type) { $this->type = $type; } public function isValid(Collection $container, $status = null) { if (!isset($_FILES[$this->field]) || $_FILES[$this->field]['error'] == UPLOAD_ERR_NO_FILE) { $this->setErrorMsg('Файл не загружен'); return false; } $tmp = $_FILES[$this->field]; if (!in_array($tmp['type'], $this->type)) { $this->setErrorMsg('Неверный формат файла'); return false; } if ($tmp['size'] > $this->maxsize*1024) { $this->setErrorMsg('Неверный размер файла'); return false; } return true; } }