{"id":1495,"date":"2020-12-29T05:02:06","date_gmt":"2020-12-29T05:02:06","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/add-file-upload-control-magento-2-admin-configuration\/"},"modified":"2025-05-21T17:22:25","modified_gmt":"2025-05-21T11:52:25","slug":"add-file-upload-control-magento-2-admin-configuration","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/add-file-upload-control-magento-2-admin-configuration\/","title":{"rendered":"How to Add File Upload Control in Magento 2 Admin Configuration"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Magento 2 admin supports multiple input types such as text box, radio button, dropdown, multi select boxes etc., the values of which stored and displayed in different forms of grids, forms, fields, images, etc.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Sometimes, while developing&nbsp;<a href=\"https:\/\/meetanshi.com\/magento-2-extensions.html\">Magento 2 extensions<\/a>, you may require to allow the admin to upload multiple files like icon image to show in the frontend or CSV with some zip codes to use the values somewhere in the extension. There are multiple file types such as PHP, XML, JPG, DOC, XLS, CSV and to allow the admin to upload files, you require to&nbsp;<strong>add file upload control in Magento 2 admin configuration<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, the default Magento 2 does not have the facility to upload files for admin configuration. Thus, I have come up with the programmatic solution to&nbsp;<em>add file upload control in Magento 2 admin configuration<\/em>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Programmatic Solution to Add File Upload Control in Magento 2 Admin Configuration<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Add the below code in&nbsp;<strong>system.xml<\/strong>&nbsp;file at&nbsp;<strong>Meetanshi\/Extension\/etc\/adminhtml\/<\/strong><br><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;field id=\"custom_file_id\" translate=\"label\" type=\"Magento\\Config\\Block\\System\\Config\\Form\\Field\\File\" sortOrder=\"10\"\n       showInDefault=\"1\" showInWebsite=\"1\" showInStore=\"1\">\n    &lt;label>File Upload Button&lt;\/label>\n    &lt;backend_model>Magento\\Config\\Model\\Config\\Backend\\File&lt;\/backend_model>\n    &lt;upload_dir config=\"system\">MyUploadDir&lt;\/upload_dir>\n&lt;\/field><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Your file will be uploaded at&nbsp;<strong>magentoRoot\/pub\/media\/MyUploadDir\/filename<em>.<\/em><\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s the only thing you need to do to add file upload control in admin configuration. You can also&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/add-custom-image-upload-control-in-magento-2-backend\/\" target=\"_blank\" rel=\"noreferrer noopener\">add custom image upload control in Magento 2 backend<\/a>&nbsp;to allow only image file type uploads in stores configuration.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Do not forget to share the post with Magento Community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Magento 2 admin supports multiple input types such as text box, radio button, dropdown, multi select boxes etc., the values of which stored and displayed&#8230;<\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1495","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1495","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1495"}],"version-history":[{"count":3,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1495\/revisions"}],"predecessor-version":[{"id":13897,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1495\/revisions\/13897"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1495"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1495"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1495"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}