3

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');
                    $uploader->setAllowRenameFiles(true);
                    $uploader->setFilesDispersion(true);
                    $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 Oct 26 '17 at 11:26

Your Answer

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

Browse other questions tagged or ask your own question.