skeeks\cms\controllers\StorageFilesController::actionRemoteUpload PHP Method

actionRemoteUpload() public method

public actionRemoteUpload ( )
    public function actionRemoteUpload()
    {
        $response = ['success' => false];
        Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
        $post = Yii::$app->request->post();
        $get = Yii::$app->getRequest();
        $request = Yii::$app->getRequest();
        if (\Yii::$app->request->post('link')) {
            $storageFile = Yii::$app->storage->upload(\Yii::$app->request->post('link'), array_merge(["name" => isset($model->name) ? $model->name : "", "original_name" => basename($post['link'])]));
            if ($request->post('modelData') && is_array($request->post('modelData'))) {
                $storageFile->setAttributes($request->post('modelData'));
            }
            $storageFile->save(false);
            $response["success"] = true;
            $response["file"] = $storageFile;
            return $response;
        }
        return $response;
    }