controllers/FilesController.php
/**
     * Creates a new Files model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
Creates a new Files model.
If creation is successful, the browser will be redirected to the 'view' page.
@return mixed
Creates a new Files model . If creation is successful the browser will be redirected to the ' view ' page . @return mixed
public function actionCreate()
    {
        $model = new Files();
        if(Yii::$app->request->isAjax) {
            Yii::$app->response->format = Response::FORMAT_JSON;
            if (Yii::$app->request->post() && $model->load(Yii::$app->request->post())) {
                return ActiveForm::validate($model);
            }
            return [
                $this->renderAjax('create', ['model'=>$model])
            ];
        } elseif ($model->load(Yii::$app->request->post()) && $model->validate()) {
            $model->upload();
            return $this->redirect(['index']);
        }
        return $this->render('create', [
            'model' => $model,
        ]);
    }
public function actionCreate ( ) { $ model = new Files ( ) ; if ( Yii :: $ app -> request -> isAjax ) { Yii :: $ app -> response -> format = Response :: FORMAT_JSON ; if ( Yii :: $ app -> request -> post ( ) && $ model -> load ( Yii :: $ app -> request -> post ( ) ) ) { return ActiveForm :: validate ( $ model ) ; } return [ $ this -> renderAjax ( 'create' , [ 'model' => $ model ] ) ] ; } elseif ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> validate ( ) ) { $ model -> upload ( ) ; return $ this -> redirect ( [ 'index' ] ) ; } return $ this -> render ( 'create' , [ 'model' => $ model , ] ) ; }
Creates a new Files model.
Creates a new Files model .
//prepare response formate