4

I am trying to upload slide image in Magento 2. In some form I have suffix in name attribute for image field like this:

<input id="slide_image" name="slide[image]" class="input-file">

My question is how can request this file in following way as I am trying to request file like this:

$this->getRequest()->getFiles('image');

I have also tried these ways with no luck

$this->getRequest()->getFiles('slide[image]');
$this->getRequest()->getFiles('slide.image');

2 Answers 2

7

Ok, I got it working with this:

$this->getRequest()->getFiles('slide')['image']
1
  • how do you save this to module image folder? Commented Sep 9, 2019 at 15:44
2

Just for information, if you want all the files inside the 'slide' array, you can use:

$this->getRequest()->getFiles('slide');

This will return a array with all the uploaded files.

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.