sjaakp / yii2-illustrated-behavior

Adds image to ActiveRecord
http://www.sjaakpriester.nl/software/illustrated
MIT License
43 stars 17 forks source link

Image not being saved #16

Open aidonsnous opened 8 years ago

aidonsnous commented 8 years ago

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 commented 8 years ago

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

f1lon commented 8 years ago

Maybe you should add

["photo","string"]

to your model`s rules ?