Magento 2 UI form Multiple image uploadMagento2 image file in ui component formMagento 2: Where are Gallery Images Processed in an Admin Save?Magento 2 : How can I upload files of dynamically added file input fields in the adminTrying to get CloudFront to work with Magento 2Magento 2 Add new field to Magento_User admin formMagento 2.1 UI Component Image upload formMagento 2 : How to upload image from frontendForm is not displayed on panel admin Magento 2Upload Multiple Images on the frontend FormImage Uploader throws Uncaught type Error in Ui Component
Moons and messages
Why is this integration method not valid?
How to deceive the MC
I want to ask company flying me out for office tour if I can bring my fiance
Flatten not working
Can a UK national work as a paid shop assistant in the USA?
To exponential digit growth and beyond!
Why this character is punished instead of being honoured?
relative price of a transistor and a capacitor
Why is the Eisenstein ideal paper so great?
Does water in vacuum form a solid shell or freeze solid?
How to create a `range`-like iterable object of floats?
Can flying creatures choose to hover, even if they don't have hover in their flying speed?
Can a multiclassed Kensei monk/Swashbuckler rogue use an offhand finesse weapon to trigger Sneak Attack, without using a bonus action?
First Program Tic-Tac-Toe
How does Dreadhorde Arcanist interact with split cards?
Cisco 3750X Power Cable
Using too much dialogue?
What would prevent living skin from being a good conductor for magic?
Piping the output of comand columns
Possibility of faking someone's public key
Why do testers need root cause analysis?
How would a developer who mostly fixed bugs for years at a company call out their contributions in their CV?
The disk image is 497GB smaller than the target device
Magento 2 UI form Multiple image upload
Magento2 image file in ui component formMagento 2: Where are Gallery Images Processed in an Admin Save?Magento 2 : How can I upload files of dynamically added file input fields in the adminTrying to get CloudFront to work with Magento 2Magento 2 Add new field to Magento_User admin formMagento 2.1 UI Component Image upload formMagento 2 : How to upload image from frontendForm is not displayed on panel admin Magento 2Upload Multiple Images on the frontend FormImage Uploader throws Uncaught type Error in Ui Component
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have implemented multiple image upload using the following code.
<field name="press_images">
<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">press_images</item>
<item name="label" xsi:type="string" translate="true">Image</item>
<item name="visible" xsi:type="boolean">true</item>
<item name="formElement" xsi:type="string">imageUploader</item>
<item name="elementTmpl" xsi:type="string">ui/form/element/uploader/uploader</item>
<item name="previewTmpl" xsi:type="string">Magento_Catalog/image-preview</item>
<item name="isMultipleFiles" xsi:type="boolean">true</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
<item name="uploaderConfig" xsi:type="array">
<item name="url" xsi:type="url" path="pressfeature/image/upload"/>
</item>
</item>
</argument>
</field>
I used https://github.com/Turiknox/magento2-sample-imageuploader way to upload images. The image uploading works fine. When you browser the image and choose it. Then a controller gets fired which uploads all images in temp folder using an ajax call. When i click save button the image data and other data is send correctly.
My question is how should i save this filename in database so when i click edit i should see both images in edit form.
magento2 magento-2.1 uicomponent
add a comment |
I have implemented multiple image upload using the following code.
<field name="press_images">
<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">press_images</item>
<item name="label" xsi:type="string" translate="true">Image</item>
<item name="visible" xsi:type="boolean">true</item>
<item name="formElement" xsi:type="string">imageUploader</item>
<item name="elementTmpl" xsi:type="string">ui/form/element/uploader/uploader</item>
<item name="previewTmpl" xsi:type="string">Magento_Catalog/image-preview</item>
<item name="isMultipleFiles" xsi:type="boolean">true</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
<item name="uploaderConfig" xsi:type="array">
<item name="url" xsi:type="url" path="pressfeature/image/upload"/>
</item>
</item>
</argument>
</field>
I used https://github.com/Turiknox/magento2-sample-imageuploader way to upload images. The image uploading works fine. When you browser the image and choose it. Then a controller gets fired which uploads all images in temp folder using an ajax call. When i click save button the image data and other data is send correctly.
My question is how should i save this filename in database so when i click edit i should see both images in edit form.
magento2 magento-2.1 uicomponent
1
This is custom image? where you want to save it? in custom table?
– Rutvee Sojitra
May 16 at 5:24
Only the name of the file but the file will be moved from tmp directory to <module media> directory.
– Avesh Naik
May 16 at 5:30
1
But where you want to insert filename in DB?
– Rutvee Sojitra
May 16 at 5:31
Yes in database.
– Avesh Naik
May 16 at 5:32
Thank you for the help. Got the solution.
– Avesh Naik
May 16 at 5:36
add a comment |
I have implemented multiple image upload using the following code.
<field name="press_images">
<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">press_images</item>
<item name="label" xsi:type="string" translate="true">Image</item>
<item name="visible" xsi:type="boolean">true</item>
<item name="formElement" xsi:type="string">imageUploader</item>
<item name="elementTmpl" xsi:type="string">ui/form/element/uploader/uploader</item>
<item name="previewTmpl" xsi:type="string">Magento_Catalog/image-preview</item>
<item name="isMultipleFiles" xsi:type="boolean">true</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
<item name="uploaderConfig" xsi:type="array">
<item name="url" xsi:type="url" path="pressfeature/image/upload"/>
</item>
</item>
</argument>
</field>
I used https://github.com/Turiknox/magento2-sample-imageuploader way to upload images. The image uploading works fine. When you browser the image and choose it. Then a controller gets fired which uploads all images in temp folder using an ajax call. When i click save button the image data and other data is send correctly.
My question is how should i save this filename in database so when i click edit i should see both images in edit form.
magento2 magento-2.1 uicomponent
I have implemented multiple image upload using the following code.
<field name="press_images">
<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">press_images</item>
<item name="label" xsi:type="string" translate="true">Image</item>
<item name="visible" xsi:type="boolean">true</item>
<item name="formElement" xsi:type="string">imageUploader</item>
<item name="elementTmpl" xsi:type="string">ui/form/element/uploader/uploader</item>
<item name="previewTmpl" xsi:type="string">Magento_Catalog/image-preview</item>
<item name="isMultipleFiles" xsi:type="boolean">true</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
<item name="uploaderConfig" xsi:type="array">
<item name="url" xsi:type="url" path="pressfeature/image/upload"/>
</item>
</item>
</argument>
</field>
I used https://github.com/Turiknox/magento2-sample-imageuploader way to upload images. The image uploading works fine. When you browser the image and choose it. Then a controller gets fired which uploads all images in temp folder using an ajax call. When i click save button the image data and other data is send correctly.
My question is how should i save this filename in database so when i click edit i should see both images in edit form.
magento2 magento-2.1 uicomponent
magento2 magento-2.1 uicomponent
asked May 16 at 5:21
Avesh NaikAvesh Naik
480114
480114
1
This is custom image? where you want to save it? in custom table?
– Rutvee Sojitra
May 16 at 5:24
Only the name of the file but the file will be moved from tmp directory to <module media> directory.
– Avesh Naik
May 16 at 5:30
1
But where you want to insert filename in DB?
– Rutvee Sojitra
May 16 at 5:31
Yes in database.
– Avesh Naik
May 16 at 5:32
Thank you for the help. Got the solution.
– Avesh Naik
May 16 at 5:36
add a comment |
1
This is custom image? where you want to save it? in custom table?
– Rutvee Sojitra
May 16 at 5:24
Only the name of the file but the file will be moved from tmp directory to <module media> directory.
– Avesh Naik
May 16 at 5:30
1
But where you want to insert filename in DB?
– Rutvee Sojitra
May 16 at 5:31
Yes in database.
– Avesh Naik
May 16 at 5:32
Thank you for the help. Got the solution.
– Avesh Naik
May 16 at 5:36
1
1
This is custom image? where you want to save it? in custom table?
– Rutvee Sojitra
May 16 at 5:24
This is custom image? where you want to save it? in custom table?
– Rutvee Sojitra
May 16 at 5:24
Only the name of the file but the file will be moved from tmp directory to <module media> directory.
– Avesh Naik
May 16 at 5:30
Only the name of the file but the file will be moved from tmp directory to <module media> directory.
– Avesh Naik
May 16 at 5:30
1
1
But where you want to insert filename in DB?
– Rutvee Sojitra
May 16 at 5:31
But where you want to insert filename in DB?
– Rutvee Sojitra
May 16 at 5:31
Yes in database.
– Avesh Naik
May 16 at 5:32
Yes in database.
– Avesh Naik
May 16 at 5:32
Thank you for the help. Got the solution.
– Avesh Naik
May 16 at 5:36
Thank you for the help. Got the solution.
– Avesh Naik
May 16 at 5:36
add a comment |
1 Answer
1
active
oldest
votes
Got the solution, Changes need to dataProvider file.
public function getData()
if (isset($this->_loadedData))
return $this->_loadedData;
$items = $this->collection->getItems();
foreach ($items as $item)
if ($item->getDefaultImage())
$img['default_image'][0]['name'] = $item->getDefaultImage();
$img['default_image'][0]['url'] = $this->getMediaUrl()."/".$item->getDefaultImage();
$fullData = $item->getData();
$this->_loadedData[$item->getId()] = array_merge($fullData, $img);
else
$this->_loadedData[$item->getId()] = $item->getData();
return $this->_loadedData;
FROM THIS
$img['default_image'][0]['name'] = $item->getDefaultImage();
$img['default_image'][0]['url'] = $this->getMediaUrl()."/".$item->getDefaultImage();
TO THIS
$img['default_image'][$i]['name'] = $item->getDefaultImage();
$img['default_image'][$i]['url'] = $this->getMediaUrl()."/".$item->getDefaultImage();
where $i is the number of image uploaded. save all file names in an array in database.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f274797%2fmagento-2-ui-form-multiple-image-upload%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Got the solution, Changes need to dataProvider file.
public function getData()
if (isset($this->_loadedData))
return $this->_loadedData;
$items = $this->collection->getItems();
foreach ($items as $item)
if ($item->getDefaultImage())
$img['default_image'][0]['name'] = $item->getDefaultImage();
$img['default_image'][0]['url'] = $this->getMediaUrl()."/".$item->getDefaultImage();
$fullData = $item->getData();
$this->_loadedData[$item->getId()] = array_merge($fullData, $img);
else
$this->_loadedData[$item->getId()] = $item->getData();
return $this->_loadedData;
FROM THIS
$img['default_image'][0]['name'] = $item->getDefaultImage();
$img['default_image'][0]['url'] = $this->getMediaUrl()."/".$item->getDefaultImage();
TO THIS
$img['default_image'][$i]['name'] = $item->getDefaultImage();
$img['default_image'][$i]['url'] = $this->getMediaUrl()."/".$item->getDefaultImage();
where $i is the number of image uploaded. save all file names in an array in database.
add a comment |
Got the solution, Changes need to dataProvider file.
public function getData()
if (isset($this->_loadedData))
return $this->_loadedData;
$items = $this->collection->getItems();
foreach ($items as $item)
if ($item->getDefaultImage())
$img['default_image'][0]['name'] = $item->getDefaultImage();
$img['default_image'][0]['url'] = $this->getMediaUrl()."/".$item->getDefaultImage();
$fullData = $item->getData();
$this->_loadedData[$item->getId()] = array_merge($fullData, $img);
else
$this->_loadedData[$item->getId()] = $item->getData();
return $this->_loadedData;
FROM THIS
$img['default_image'][0]['name'] = $item->getDefaultImage();
$img['default_image'][0]['url'] = $this->getMediaUrl()."/".$item->getDefaultImage();
TO THIS
$img['default_image'][$i]['name'] = $item->getDefaultImage();
$img['default_image'][$i]['url'] = $this->getMediaUrl()."/".$item->getDefaultImage();
where $i is the number of image uploaded. save all file names in an array in database.
add a comment |
Got the solution, Changes need to dataProvider file.
public function getData()
if (isset($this->_loadedData))
return $this->_loadedData;
$items = $this->collection->getItems();
foreach ($items as $item)
if ($item->getDefaultImage())
$img['default_image'][0]['name'] = $item->getDefaultImage();
$img['default_image'][0]['url'] = $this->getMediaUrl()."/".$item->getDefaultImage();
$fullData = $item->getData();
$this->_loadedData[$item->getId()] = array_merge($fullData, $img);
else
$this->_loadedData[$item->getId()] = $item->getData();
return $this->_loadedData;
FROM THIS
$img['default_image'][0]['name'] = $item->getDefaultImage();
$img['default_image'][0]['url'] = $this->getMediaUrl()."/".$item->getDefaultImage();
TO THIS
$img['default_image'][$i]['name'] = $item->getDefaultImage();
$img['default_image'][$i]['url'] = $this->getMediaUrl()."/".$item->getDefaultImage();
where $i is the number of image uploaded. save all file names in an array in database.
Got the solution, Changes need to dataProvider file.
public function getData()
if (isset($this->_loadedData))
return $this->_loadedData;
$items = $this->collection->getItems();
foreach ($items as $item)
if ($item->getDefaultImage())
$img['default_image'][0]['name'] = $item->getDefaultImage();
$img['default_image'][0]['url'] = $this->getMediaUrl()."/".$item->getDefaultImage();
$fullData = $item->getData();
$this->_loadedData[$item->getId()] = array_merge($fullData, $img);
else
$this->_loadedData[$item->getId()] = $item->getData();
return $this->_loadedData;
FROM THIS
$img['default_image'][0]['name'] = $item->getDefaultImage();
$img['default_image'][0]['url'] = $this->getMediaUrl()."/".$item->getDefaultImage();
TO THIS
$img['default_image'][$i]['name'] = $item->getDefaultImage();
$img['default_image'][$i]['url'] = $this->getMediaUrl()."/".$item->getDefaultImage();
where $i is the number of image uploaded. save all file names in an array in database.
answered May 16 at 5:36
Avesh NaikAvesh Naik
480114
480114
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f274797%2fmagento-2-ui-form-multiple-image-upload%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
This is custom image? where you want to save it? in custom table?
– Rutvee Sojitra
May 16 at 5:24
Only the name of the file but the file will be moved from tmp directory to <module media> directory.
– Avesh Naik
May 16 at 5:30
1
But where you want to insert filename in DB?
– Rutvee Sojitra
May 16 at 5:31
Yes in database.
– Avesh Naik
May 16 at 5:32
Thank you for the help. Got the solution.
– Avesh Naik
May 16 at 5:36