I have uploaded single image successfully by below code.

$uploader = $this->_objectManager->create('\Magento\MediaStorage\Model\File\Uploader',['fileId'=>'image_photo']);

                    $uploader->setAllowedExtensions(['jpg', 'jpeg', 'gif', 'png']);
                    $imageAdapter = $this->_objectManager->get('Magento\Framework\Image\AdapterFactory')->create();
                    $uploader->addValidateCallback('image_photo', $imageAdapter, 'validateUploadFile');
                    $result = $uploader->save($mediaDirectory->getAbsolutePath(\{{namespace}}\{{module_name}}\Model\Image::BASE_MEDIA_PATH));

We also get multiple file object in a controller. Could anyone please guide how we can achieve upload for multiple files as well?

  • Did you get this stuff done if so could you please share your code?
    – Dev
    Commented Oct 26, 2017 at 11:26


Your Answer

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