I'm developing an admin grid list. In the edit form i have an image field, but when i save it it does't appear in:

$data = $this->getRequest()->getPostValue();

and in:

$data = $this->getRequest();

I can see:

  protected 'postParams' => 
      private 'storage' (ArrayObject) => 
        array (size=9)
          'form_key' => string 'gSliqxNCIitA25WV' (length=16)
          'entity_id' => string '9' (length=1)
          'name' => string 'bla' (length=3)
          'surname' => string 'bla' (length=3)
          'email' => string 'bla' (length=3)
          'company' => string 'bla' (length=3)
          'note' => string 'bla' (length=3)
          'store_id' => string '1' (length=1)
          'url_key' => string 'bla' (length=3)
  protected 'fileParams' => 
      private 'storage' (ArrayObject) => 
        array (size=1)
          'image' => 
            array (size=5)
  protected 'version' => string '1.1' (length=3)
  protected 'headers' => 
      protected 'pluginClassLoader' => 
          protected 'plugins' => 
            array (size=55)

And maybe i can get the image from the 'fileParams', but i don't know how. I already tried: var_dump($this->getRequest()->getParams());

so, any idea?

4 Answers 4


This happens as your post data does not contain the information about the image file. It is stored in $_FILES.

So, Use Magento-2's Uploader To upload the file. Collect the post params in Request (lets say in $data ) and store the uploaded file name (from uploader result) in the $data under the same key as your field name in database.

Use this Modified $data for saving.


First set form in <form enctype="multipart/form-data"> and Check controller file in like

if (isset($_FILES['image']) && isset($_FILES['image']['name']) && strlen($_FILES['image']['name'])) {
 echo $_FILES['image']['name'];

I got the information for my issue.

I got that in $_FILES.


Try below code to get image data in controller.

$bgImage = $this->getRequest()->getFiles('bg_image'); // replace with Image field name
$fileName = ($bgImage && array_key_exists('name', $bgImage)) ? $bgImage['name'] : null;
            if ($bgImage && $fileName) {
                try {
                    $uploader = $this->_objectManager->create(
                        ['fileId' => 'bg_image']

                $uploader->setAllowedExtensions(['jpg', 'jpeg', 'gif', 'png']);

                $imageAdapterFactory = $this->_objectManager->get('Magento\Framework\Image\AdapterFactory')


                $mediaDirectory = $this->_objectManager->get('Magento\Framework\Filesystem')

                $result = $uploader->save(
            } catch (\Exception $e) {
                if ($e->getCode() == 0) {

Your Answer

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

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