Sprawdza czy odebrano już cały plik i wywołuje akcje na zakończenie uploadu,
między innymi zapis pliku i rekordu do bazy
@return boolean
331680
private function _ifComplete()
    {
        //jeśli są kawałki i nie jest to ostatni kawałek, wychodzi z true
        if ($this->_chunks && $this->_chunk != $this->_chunks - 1) {
            return true;
        }
        //zamiana nazwy
        if (!rename($this->_filePathPart, $this->_filePath)) {
            $this->_setError(PLUPLOAD_MOVE_ERR);
            return false;
        }
        //zapis rekordu pliku
        if (!$this->_saveFile()) {
            if ($this->_errorCode === null) {
                $this->_setError(PLUPLOAD_MOVE_ERR);
            }
            return false;
        }
        return true;
    }
1056200
public function flush()
    {
        //bufor nieaktywny
        if (!$this->isActive()) {
            return;
        }
        //czyszczenie rejestru
        $this->getRegistry()->setOptions([], true);
        //czyszczenie do handler
        $this->_handler->deleteAll();
    }
924078
protected function validateUpload()
    {
        $file = $this->request->file('file');

        if (empty($file)) {
            $this->setError('file', $this->text('Nothing to install'));
            return false;
        }

        $result = $this->file_transfer->upload($file, 'zip', gplcart_file_private_module('installer'));

        if ($result !== true) {
            $this->setError('file', $result);
            return false;
        }

        $this->setSubmitted('file', $this->file_transfer->getTransferred());
        return !$this->hasErrors();
    }
39118
public function uploadFile()
    {
        if (!$this->request->files->has('file')) {
            return false;
        }
        $file   = $this->request->files->get('file');
        $upload = rtrim($this->uploadDir, '/');
        if (!is_dir($upload)) {
            mkdir($upload, 0777, true);
        }
        $file->move(realpath($upload), $file->getClientOriginalName());

        return sprintf('/%s/%s', pathinfo($upload, PATHINFO_BASENAME),
            pathinfo($file->getClientOriginalName(), PATHINFO_BASENAME));
    }
912031
public function stickAction()
    {
        $this->getResponse()->setTypePlain();
        //brak id
        if (!$this->id) {
            return '';
        }
        //brak pliku
        if (null === ($file = (new CmsFileQuery)->findPk($this->id)) || $this->hash != $file->name) {
            return $this->view->getTranslate()->_('Przypinanie nie powiodło się');
        }
        //przypina plik
        $file->setSticky();
        return '';
    }
283111
protected function _update()
    {
        \App\Registry::$cache->remove('category-attributes-' . $this->id);
        //zmodyfikowany szablon
        if ($this->isModified('cmsCategoryTypeId')) {
            //iteracja po różnicy międy obecnymi atrybutami a nowymi
            foreach (array_diff(
                //obecne id atrybutów
                (new AttributeRelationModel('cmsCategoryType', $this->getInitialStateValue('cmsCategoryTypeId')))->getAttributeIds(),
                //nowe id atrybutów
                (new AttributeRelationModel('cmsCategoryType', $this->cmsCategoryTypeId))->getAttributeIds())
            as $deletedAttributeId) {
                //usuwanie wartości usuniętego atrybutu
                (new AttributeValueRelationModel('category', $this->id))
                    ->deleteAttributeValueRelationsByAttributeId($deletedAttributeId);
            }
        }
        //zmodyfikowany parent
        $parentModified = $this->isModified('parentId');
        //zmodyfikowany order
        $orderModified = $this->isModified('order');
        //zmodyfikowana aktywność
        $activeModified = $this->isModified('active');
        //zmodyfikowane uri
        $uriModified = $this->isModified('uri');
        //data modyfikacji
        $this->dateModify = date('Y-m-d H:i:s');
        //aktualizacja rekordu
        if (!parent::_update()) {
            return false;
        }
        //sortowanie dzieci po przestawieniu rodzica, lub kolejności
        if (($parentModified || $orderModified) && !$this->getOption('block-ordering')) {
            //sortuje dzieci
            $this->_sortChildren();
        }
        //zmieniono parenta, nazwę, lub aktywność
        if ($parentModified || $uriModified || $activeModified) {
            //przebudowa dzieci
            $this->_rebuildChildren($this->id);
        }
        //synchronizacja draftów
        if ($parentModified || $uriModified || $activeModified || $orderModified) {
            //synchronizacja pól w draftach
            $this->_synchronizeDrafts();
        }
        return true;
    }
889685
public function afterSave()
        {
                //jeśli czegoś nie uddało się zapisać wcześniej
                if (!parent::afterSave()) {
                        return false;
                }
                //jeśli nie udało się zapisać powiązań z rolami
                if (!$this->_saveRoles()) {
                        return false;
                }
                //commit wersji
                if ($this->getElement('commit')->getValue()) {
                        $this->getRecord()->commitVersion();
                }
                //usunięcie locka
                return (new CategoryLockModel($this->getRecord()->cmsCategoryOriginalId))->releaseLock();
        }
1314013
private static function areFileUploadsEnabled() {
		if (self::parseIniBoolean(\ini_get('file_uploads')) === false) {
			return false;
		}

		if (((int) \ini_get('max_file_uploads')) <= 0) {
			return false;
		}

		return true;
	}
640207
protected function uploadFile () : bool
	{
		// Determine the destination
		$this->newFileLocation = $this->getUploadDir().$this->uploadFileDir.getConstant('DS', TRUE).$this->newFileName;			  
		// Make sure a file doesn't already exist in the target location
		if (file_exists($this->newFileLocation)):
			$this->error = "The file {$this->newFileLocation} already exists.";
			return FALSE;
		endif;
		// Attempt to move/upload the file 
		if (!move_uploaded_file($this->tempPath, $this->newFileLocation)):
			// File was not moved - failure.
			$this->error = "The file upload failed.";
			return FALSE;
		endif;
		// SUCCESS
		return TRUE;
	}
157113
public function upload()
    {
        // validate that all options properties was properly set to correct type.
        $this->validateOptionsProperties();
        // setup file extensions and mime types for validation. (in case that it was not set).
        $this->setupFileExtensionsMimeTypesForValidation();

        // verify that location where the uploaded file(s) will be moved to is writable.
        if (!is_dir($this->move_uploaded_to)) {
            $this->setErrorMessage(
                static::__('The target location where the uploaded file(s) will be moved to is not folder or directory.'),
                'RDU_MOVE_UPLOADED_TO_NOT_DIR',
                $this->move_uploaded_to
            );
            return false;
        } elseif (is_dir($this->move_uploaded_to) && !is_writable($this->move_uploaded_to)) {
            $this->setErrorMessage(
                static::__('The target location where the uploaded file(s) will be moved to is not writable. Please check the folder permission.'),
                'RDU_MOVE_UPLOADED_TO_NOT_WRITABLE',
                $this->move_uploaded_to
            );
            return false;
        } else {
            // solve the move uploaded to as a real path.
            $this->move_uploaded_to = realpath($this->move_uploaded_to);
        }

        if (isset($_FILES[$this->input_file_name]['name']) && is_array($_FILES[$this->input_file_name]['name'])) {
            // if multiple file upload.
            foreach ($_FILES[$this->input_file_name]['name'] as $key => $value) {
                $this->files[$this->input_file_name]['input_file_key'] = $key;
                $this->files[$this->input_file_name]['name'] = $_FILES[$this->input_file_name]['name'][$key];
                $this->files[$this->input_file_name]['type'] = (isset($_FILES[$this->input_file_name]['type'][$key]) ? $_FILES[$this->input_file_name]['type'][$key] : null);
                $this->files[$this->input_file_name]['tmp_name'] = (isset($_FILES[$this->input_file_name]['tmp_name'][$key]) ? $_FILES[$this->input_file_name]['tmp_name'][$key] : null);
                $this->files[$this->input_file_name]['error'] = (isset($_FILES[$this->input_file_name]['error'][$key]) ? $_FILES[$this->input_file_name]['error'][$key] : 4);
                $this->files[$this->input_file_name]['size'] = (isset($_FILES[$this->input_file_name]['size'][$key]) ? $_FILES[$this->input_file_name]['size'][$key] : 0);

                $result = $this->uploadSingleFile();

                if ($result == false && $this->stop_on_failed_upload_multiple === true) {
                    // it was set to sop on failed to upload multiple file. return false.
                    unset($result);
                    return false;
                }
            }// endforeach;
            unset($key, $value);
        } else {
            // if single file upload.
            $this->files[$this->input_file_name] = $_FILES[$this->input_file_name];
            $this->files[$this->input_file_name]['input_file_key'] = 0;

            $result = $this->uploadSingleFile();
        }

        if (isset($result) && $result == false && $this->stop_on_failed_upload_multiple === true) {
            // there is at lease one upload error and it was set to stop on error.
            unset($result);
            $this->clearUploadedAtTemp();
            return false;
        } elseif (count($this->error_messages) > 0 && $this->stop_on_failed_upload_multiple === true) {
            // there is at lease one upload error and it was set to stop on error.
            unset($result);
            $this->clearUploadedAtTemp();
            return false;
        }

        return $this->moveUploadedFiles();
    }
1320944
public function upload(): bool
    {
        $saved = $this->save();

        // ignore saving error
        $this->uploadFile($this->aliasConfig->getFileDirectory($this), $this->aliasConfig->getFileName($this));

        return $saved;
    }
776878
public function transport(){

            $target = ($this->target === "") ? "":$this->target."/";
            $targetFileName = sprintf('%s%s.%s', $target, $this->newName, $this->ext);

            // eğer dosya varsa siler
            if(file_exists($targetFileName)){
                unlink($targetFileName);
            }


            if(move_uploaded_file($this->file['tmp_name'], $targetFileName)){
                chmod($targetFileName, 0777);
                return $targetFileName;
            }else{
                return false;
            }
        }
1207776
public function save()
    {
        if ($this->validate() && $this->file instanceof UploadedFile) {
            try {
                if (($uploader = $this->file->save()) != false) {
                    $this->file = $uploader->getUrl();
                    return true;
                } else {
                    $this->addError('file', Yii::t('yuncms', 'Audio file storage failed.'));
                }
            } catch (FileExistsException $e) {
                $this->addError('file', $e->getMessage());
            } catch (ErrorException $e) {
                $this->addError('file', $e->getMessage());
            } catch (InvalidConfigException $e) {
                $this->addError('file', $e->getMessage());
            }
        }
        return false;
    }
276044
public function actionFilemanagerUpdateCaption()
    {
        $this->checkRouteAccess(self::PERMISSION_ROUTE);
        
        $fileId = Yii::$app->request->post('id', false);
        $captionsText = Yii::$app->request->post('captionsText', false);
        $pageId = Yii::$app->request->post('pageId', 0);
    
        if ($fileId && is_scalar($fileId) && $captionsText) {
            $model = StorageFile::findOne($fileId);
            if ($model) {
                $model->updateAttributes([
                    'caption' => I18n::encode($captionsText),
                ]);
    
                $this->flushApiCache($model->folder_id, $pageId);
    
                return true;
            }
        }
    
        return false;
    }
362004
public function pluploadAction()
    {
        set_time_limit(5 * 60);
        //obiekt handlera plupload
        $pluploadHandler = new Model\PluploadHandler();
        //jeśli wystąpił błąd
        if (!$pluploadHandler->handle()) {
            return $this->_jsonError($pluploadHandler->getErrorCode(), $pluploadHandler->getErrorMessage());
        }
        //jeśli wykonać operację po przesłaniu całego pliku i zapisaniu rekordu
        if ($this->getPost()->afterUpload && null !== $record = $pluploadHandler->getSavedCmsFileRecord()) {
            $this->_operationAfter($this->getPost()->afterUpload, $record);
        }
        return json_encode(['result' => 'OK', 'cmsFileId' => $pluploadHandler->getSavedCmsFileId()]);
    }
1319278
public function releaseLock()
    {
        //wyszukiwanie blokady dla kategorii
        if (null === $lockRecord = (new CacheQuery)->findPk($lockKey = self::CACHE_PREFIX . $this->_categoryId)) {
            //brak blokady
            return true;
        }
        //zwalnianie blokady z opóźnieniem
        $lockRecord->ttl = time() + self::RELEASE_TIMEOUT;
        return $lockRecord->save();
    }
1041126
public function beforeSave()
    {
        $tag = $this->getElement('tag')->getValue();
        //wyszukanie tagu
        if (null === $tagRecord = (new \Cms\Orm\CmsTagQuery)
            ->whereTag()->equals($tag)
            ->findFirst()) {
            //utworzenie tagu
            $tagRecord = new \Cms\Orm\CmsTagRecord;
            $tagRecord->tag = $tag;
            $tagRecord->save();
        }
        //przypisanie id tagu
        $this->getRecord()->cmsTagId = $tagRecord->id;
        return true;
    }