pendalf89\filemanager\controllers\FileController::actionUpload PHP Method

actionUpload() public method

Provides upload file
public actionUpload ( ) : mixed
return mixed
    public function actionUpload()
    {
        Yii::$app->response->format = Response::FORMAT_JSON;
        $model = new Mediafile();
        $routes = $this->module->routes;
        $rename = $this->module->rename;
        $tagIds = Yii::$app->request->post('tagIds');
        if ($tagIds !== 'undefined') {
            $model->setTagIds(explode(',', $tagIds));
        }
        $model->saveUploadedFile($routes, $rename);
        $bundle = FilemanagerAsset::register($this->view);
        if ($model->isImage()) {
            $model->createThumbs($routes, $this->module->thumbs);
        }
        $response['files'][] = ['url' => $model->url, 'thumbnailUrl' => $model->getDefaultThumbUrl($bundle->baseUrl), 'name' => $model->filename, 'type' => $model->type, 'size' => $model->file->size, 'deleteUrl' => Url::to(['file/delete', 'id' => $model->id]), 'deleteType' => 'POST'];
        return $response;
    }