/** * Creates a new Survey model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Survey(); if ($model->load(Yii::$app->request->post())) { //上传文件 //$imageName = $model->name; //$model->file = UploadedFile::getInstance($model, 'file'); //if ($model->file && $model->validate()){ //$model->file->saveAs( 'uploads/' . $model->file->baseName . '.' . $model->file->extension); //$model->logo='uploads/'.$imageName.'.jpg'; //} //$model->file->saveAs('uploads/' . $imageName . '.' . $model->file->extension); //存储地址在数据库 $model->save(); return $this->redirect(['view', 'id' => $model->id]); } else { return $this->renderAjax('create', ['model' => $model]); } }