0

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?

1 Answer 1

1

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'
              ]
    ]
);

....
....
....

$form->setUseContainer(true);
$this->setForm($form);

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

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.