public function beforeSave() { /*if ($this->fileupload instanceof CUploadedFile) { $mainName = $newName = STranslate::transliter($this->fileupload->getName()); $i = 1; while (file_exists($this->getPathDirStoredFile() . '/' . $newName)) { $parts = explode('.', $mainName); $countParts = count($parts); if ($countParts > 1) { unset($parts[$countParts - 1]); $newName = implode($parts) . '(' . $i . ').' . $this->fileupload->extensionName; } else { $newName = '(' . $i . ')' . $mainName; } $i++; } if (!file_exists($this->getPathDirStoredFile())) mkdir($this->getPathDirStoredFile(),0755,true); $this->fileupload->saveAs($this->getPathDirStoredFile() . '/' . $newName); $this->file = $newName; if (!empty($this->old_file)) { $delete = $this->getPathDirStoredFile() . '/' . $this->old_file; if (file_exists($delete)) { unlink($delete); } } } if (empty($this->file) && !empty($this->old_file)) { $this->file = $this->old_file; }*/ $this->file = Tools::saveUploadedFile($this->fileupload, $this->getPathDirStoredFile(), $this->file); return parent::beforeSave(); }
public function beforeSave() { $this->logo = Tools::saveUploadedFile($this->fileupload, Yii::getPathOfAlias('webroot') . '/' . $this->getFilesPath(), $this->logo); $this->icon = Tools::saveUploadedFile($this->iconupload, Yii::getPathOfAlias('webroot') . '/' . $this->getFilesPath(), $this->icon); return parent::beforeSave(); }