/** * @inheritdoc */ public function validate($input) { $maxValue = $this->params['maxValue']; if ($input instanceof UploadedFile) { if ($input->error === UPLOAD_ERR_INI_SIZE || $input->error === UPLOAD_ERR_FORM_SIZE) { return false; } $input = $input->size; $maxValue = UploadedFile::getSizeLimit($maxValue); } elseif ($input instanceof \SplFileInfo) { $input = $input->getSize(); } if ($this->params['inclusive']) { return $input <= $maxValue; } else { return $input < $maxValue; } }
protected function prepareAttributes() { foreach ($this->prepareAttributes as $attributeName => $type) { if (isset($this->model->{$attributeName})) { if (class_exists('\\rock\\file\\UploadedFile')) { if ($type == 'file') { $this->model->{$attributeName} = UploadedFile::getInstance($this->model, $attributeName); } elseif ($type == 'multiFiles') { $this->model->{$attributeName} = UploadedFile::getInstances($this->model, $attributeName); } } } } }