Upload multiple media at once

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
JakeTheDog420
Posts: 2
Joined: 06 Aug 2021, 16:57

Upload multiple media at once

Post by JakeTheDog420 » 06 Aug 2021, 17:04

Hi,

I'm very new to aimeos! Is adapting the default admin panels upload function, to allow for multiple uploads at once possible?

It's very inconvenient to have to press the "+" button individually, for each new product photo. Instead I'd like to be able to simply press it once, select all the photos desired for upload, and have the repetitive parts done for me in the background.

Basically a bulk media upload option.
Any help is greatly appreciated!

Thanks.

UPDATE:
PHP 7.3.27-1~deb10u1 (cli) (built: Feb 13 2021 16:31:40) ( NTS )
Newest Stable Aimeos (pre-built store) (as of 6th August 2021)
Windows (But running server on Debian WSL)

User avatar
aimeos
Administrator
Posts: 7865
Joined: 01 Jan 1970, 00:00

Re: Upload multiple media at once

Post by aimeos » 07 Aug 2021, 10:26

You can add a multiple file upload control here:
https://github.com/aimeos/ai-admin-jqad ... rd.php#L31

Then, you have to add a few lines of code to loop over the files here:
https://github.com/aimeos/ai-admin-jqad ... d.php#L363

We would appreciate a pull request with your changes very much and will merge it into the core :-)
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

JakeTheDog420
Posts: 2
Joined: 06 Aug 2021, 16:57

Re: Upload multiple media at once

Post by JakeTheDog420 » 07 Aug 2021, 21:02

Hi, thanks for your reply!

I've gone through the files you referenced, but I'm not sure that I understand the way (https://github.com/aimeos/ai-admin-jqad ... d.php#L363) works in relation to the input form... :oops:

I've edited the first file, you linked to; I added the relevant code to allow for multiple files to be uploaded... (See below)
(https://github.com/JTD420/ai-admin-jqad ... hp#L68-L70)

If you could offer me some additional help, in how to go about looping through the results of this, in order to store multiple files, I'd really appreciate it! And of course, I'll happily submit a pull request, should I manage to get it working, that is.. :lol:


(I was looking at code examples, such as this one.. So I know at a base level, fundamentally, this should be incredibly simple... :oops: 😩 )
https://makitweb.com/multiple-files-upl ... -with-php/

User avatar
aimeos
Administrator
Posts: 7865
Joined: 01 Jan 1970, 00:00

Re: Upload multiple media at once

Post by aimeos » 08 Aug 2021, 06:44

JakeTheDog420 wrote: 07 Aug 2021, 21:02 I've edited the first file, you linked to; I added the relevant code to allow for multiple files to be uploaded... (See below)
(https://github.com/JTD420/ai-admin-jqad ... hp#L68-L70)
This won't give your the desired result because it will upload multiple files for one media item. There might be a much better solution which requires a few lines of HTML and JS only:

1.) Add a hidden multiple file input field and change the <div> to a <label> with a "for" attribute, so the file dialog is automatically opened when the label is clicked:
https://github.com/JTD420/ai-admin-jqad ... #L248-L251

Code: Select all

<label for="media-multiple-add" class="btn btn-primary btn-card-more act-add fa" ... v-on:change="addMultiple($event)"></label>
<input type="file" id="media-multiple-add" style="display:none"/>
2.) Implement the new addMultiple() method here and use add() once for each file (extend the add() method by a fileobject parameter):
https://github.com/aimeos/ai-admin-jqad ... ux.js#L183
Use the DataTransfer API of the browser to move the files to from the multiple file dialog to the single file dialogs:
https://stackoverflow.com/questions/425 ... ther-input
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply