public function afterValidate($event) { parent::afterValidate($event); if ($this->checkScenario() && !$this->owner->hasErrors()) { $modelName = get_class($this->owner); if (isset($_FILES[$modelName]['name'][$this->attributeName])) { $files = array(); foreach ($_FILES[$modelName] as $k => $v) { $files[$k] = $v[$this->attributeName]; } // Сохраняю if ($files) { Yii::import('ext.ImageUpload.ImageUpload'); $handle = new ImageUpload($files); if ($handle->uploaded) { $this->saveImage($handle); // Удаляю старую фотку if ($this->owner->scenario == 'update') { $this->deleteImage(); } $handle->clean(); } unset($handle, $files); } } } }