I upload photos in profile editing. For the field of loading the field has registered

<?= $form->field($model, 'image')->fileInput(); ?> 

When I submit a form, I conclude what is being transmitted.

 print_r(Yii::$app->request->post()); 

and get it

 Array ( [_csrf] => SzZPazVRNHUbRx80fSFXAAEBGz1mB1gNOG96HVwVWTBmQX8denx.Ig== [EditProfile] => Array ( [username] => zaych [email] => mail@site.ru [first_name] => Admin [second_name] => Admin [image] => ) [signup-button] => ) 

That is, the image field is empty, although I choose a photo. For the form prescribed

 'enctype' => 'multipart/form-data' 

What could be the error?

  • Because there are no files in the post - they are in the $ _FILES variable in PHP. Or UploadedFile::getInstance($model, 'image'); - in yii2. - Goncharov Alexander
  • I do this $file->image = UploadedFile::getInstance($file, 'image'); print_r($file->image); $file->image = UploadedFile::getInstance($file, 'image'); print_r($file->image); and empty - Diefair
  • Does anyone else have thoughts? - Diefair

0