I'am trying to add a field to upload image for specific user. I add field but problem is when I try save User. Image isn't uploaded and I got exception that $_FILES is empty. I followed these instructions:

Magento2 : Admin module Image upload code to display form

How to successfully upload image?


look like, the enctype for the form still not set, try update the code

  $form = $this->_formFactory->create();

to be like this :

$form = $this->_formFactory->create(
    'data' => [
               'id' => 'id_form',
               'method' => 'post',
               'enctype' => 'multipart/form-data'



you can reference to this link : Magento 2 Fail to change form encoding method to enctype='multipart/form-data'

hope this can solve your problem


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.