4

This question already has an answer here:

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

marked as duplicate by Siarhey Uchukhlebau, Rakesh Jesadiya, Qaisar Satti, benmarks Feb 16 '17 at 10:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Please see if the referenced question + answer solve your issue. – benmarks Feb 16 '17 at 10:57
  • @benmarks how can this question be duplicate of mentioned question? that question is not about ui component form. – Piyush Nov 14 '17 at 14:16
4

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

  • Thanks @Prashant.. What all changes need to be done in this code ? Do we need to create new controller action for 2nd image field ? – E.B Dec 15 '16 at 9:51
  • Yes you need to create another controller for second image – Prashant Valanda Dec 15 '16 at 10:07
  • 1
    Can you describe controller for upload image. – Prince Patel Jan 28 '17 at 12:21
  • PLEASE GIVE A CLEARE ANSWER – Zorox May 13 '18 at 15:19
  • 1
    Thanks, i understand it earlier, it go to controller Upload.php :) – fudu Aug 17 '18 at 1:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.