5

In my admin form I need 2 image upload field. I have added an image upload field using the below code.

mymodule_form.xml

<field name="image">
    <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
            <item name="dataType" xsi:type="string">string</item>
            <item name="source" xsi:type="string">store_logo</item>
            <item name="label" xsi:type="string" translate="true">Product Page Label</item>
            <item name="visible" xsi:type="boolean">true</item>
            <item name="formElement" xsi:type="string">fileUploader</item>
            <item name="previewTmpl" xsi:type="string">Magento_Catalog/image-preview</item>
            <item name="elementTmpl" xsi:type="string">ui/form/element/uploader/uploader</item>
            <item name="required" xsi:type="boolean">false</item>
            <item name="uploaderConfig" xsi:type="array">
                <item name="url" xsi:type="url" path="mymodule/mymodule_storelogo/upload"/>
            </item>
        </item>
    </argument>
</field>

And I need one more field like this, but I am getting only one field upon duplicating this code. My doubt is that is it necessary to give the field name as image inorder to get image upload field ? Because when I change the field name to any other, it is showing me an error

Attention The file was not uploaded.

Please Help

E.B
  • 1,010
  • 3
  • 16
  • 30

1 Answers1

5

You need to change field name as well as below code:

<item name="uploaderConfig" xsi:type="array">
    <item name="url" xsi:type="url" path="mymodule/mymodule_storelogo/upload"/>
</item>

For more reference check this

Prashant Valanda
  • 12,659
  • 5
  • 42
  • 69