yii2-illustrated-behavior icon indicating copy to clipboard operation
yii2-illustrated-behavior copied to clipboard

Image not being saved

Open aidonsnous opened this issue 9 years ago • 2 comments

when I click the submit button of the form it is sending an ajax request to the server but it not saving the file here is my code in the controller(what am I missing in the action so that it saves the image) :

public function actionphoto(){ $model = Profile::findOne(Yii::$app->user->identity->getId()); $model->scenario='photo'; if(\Yii::$app->request->post() && $model->save()){ var_dump('Image Saved'); }

      if(\Yii::$app->request->isAjax){
          var_dump('ajax request');
          \yii::$app->end();
          return $this->renderAjax('photo',array('model'=>$model));
      }else{
          return $this->render('photo',array('model'=>$model));
      }
} 

aidonsnous avatar Dec 05 '15 07:12 aidonsnous

I changed $model->save() to $model->save(false),it is working but I don't find the file in the directory

aidonsnous avatar Dec 05 '15 10:12 aidonsnous

Maybe you should add

["photo","string"]

to your model`s rules ?

f1lon avatar Jan 20 '16 14:01 f1lon