Skip to content

Custom file upload in ui-component form

I am trying to get file upload working in a ui-component admin form. The file input field is coming from a htmlContent block. This is all sitting in a <form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd"> element.

Now the issue is that the form element is not actually being rendered as html, as such I cannot add/apply enctype="multipart/form-data" to this form and $_FILES remains empty upon submitting.

Attempts to change the uiComponent to include form element and/or enctype definition failed as it doesn’t allow usage of such elements/attributes in the ui-component file directly (collapsible.xhtml). How to move forward with this?