yii2-illustrated-behavior
yii2-illustrated-behavior copied to clipboard
Image not being saved
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));
}
}
I changed $model->save() to $model->save(false),it is working but I don't find the file in the directory
Maybe you should add
["photo","string"]
to your model`s rules ?