How to Add Custom File Upload Control in Magento 2 Backend

How to Add Custom File Upload Control in Magento 2 Backend

The default Magento 2 admin interface allows input type files such as text fields, radio buttons, dropdowns, etc. Additionally, you can extend the functionality for store configuration to add custom file upload control in Magento 2 backend. This post gives you the programmatic method for the same.

If you are a Magento 2 developer, you may require to upload a file in Magento 2 backend such as a CSV file to import shipping rates, attach user manuals on product pages, upload logo image on a specific page, etc. For these tasks, you can add custom file upload control in Magento 2 backend using the below solution.

Note: The code given here is an example to add image file upload control in Magento 2. You can tweak the code as per your business requirements.

Method to Add Custom File Upload Control in Magento 2 backend:

  1. Write below code in your Vendor/Extension/etc/adminhtml/system.xml file
  2. Create Backimage.php file at Vendor/Extension/Model/Backimage.php

That’s it.

Do not hesitate to post your doubts on the topic in the Comments section below. I’d be happy to help 🙂

I’d be very grateful if you helped share this helpful post on social media to fellow developers!

Thanks!

5
(based on 6 Reviews)

Sanjay is a co-founder at Meetanshi. He is a Certified Magento Developer who loves creating Magento E-commerce solutions. When he is not engrossed with anything related to Magento, he loves to play cricket.

Leave a Reply