Magento 2: Upload File & Image

This article shows how you can upload files and images in Magento 2. You can use this code in any custom module you build. Here’s the input file field HTML code: <input type="file" name="my_custom_file" id="my_custom_file" title="Custom File" class="input-text" data-validate="{required:true}"> Here’s the controller class file code: <?php namespace YourNamespace\YourModule\Controller; use Magento\Framework\App\Action\Context; use Magento\Framework\Message\ManagerInterface; use Magento\Framework\Filesystem; use … Read more

Magento: How to upload file?

In adminhtml, you might have the following code in any form. Here ‘logo‘ is the name of the input type file. Or, you may have any HTML Form with the File field in the frontend page. Remember that your form’s enctype should be multipart/form-data. $fieldset->addField('logo', 'file', array( 'label' => 'Small Logo', 'required' => false, 'name' … Read more

Multiple file upload using jQuery and PHP

This tutorial shows how easy it is to upload multiple files using jQuery and PHP. I have used jQuery MultiFile Plugin for this purpose. The input type file should have name in list format like “pic[]” and the class name of the input should be “multi”. <input type="file" name="pic[]" class="multi" /> Below is the complete … Read more