Multiple upload images to dynamic folder and insert to database

Do files get uploaded, or are they not uploaded and not inserted in the database?

Nothing happens. Only the ā€œclear formā€. No upload, no insert

Please zip and send me the /dmxConnect/api/uploadafbeelding/uploadafb.php file to teodor@wappler.io or as private message here so i can check it.

File is sent. Good luck with it. Hope you find out what I have been doing wrong all this time

Ok, that last one did it. My bad. It works, except for storing the file correctly name into the dbase. It stores a number instead of filename.


filename2

Well, you selected the wrong name binding. Select the ā€œnameā€ not ā€œ$nameā€.

Ok, all working now. There is something seriously wrong with my logic. Last question: is it possible to make the field ā€œvolgordeā€ to autoincrement +1 from highest number in the dbasetable?

Well just donā€™t insert anything there with the insert record step and make it auto increment in the database table config.

There can only be one auto column and it must be defined as a key. id_img is defined a key and auto increment

What is the volgorde / where it comes from initially?

Ah, volgorde is the sort order that can be changed by up/down buttons in the cms. It should be initiated by the insert to database. Like the example below

So what value are you currently inserting with the insert record? Where does that value come from?

1 Like

I tried 100. But it all inserted records will get 100 and then sorting will fail. ADDT used to have something on this, still trying to figure it out, but with my logic ā€¦ā€¦ā€¦
Should be something like highest ā€œid_img+1ā€

Personally, I would leave the volgorde blank when first uploading the images, the volgorde would be the record number. Then, after the user decides to change the volgorde, you can assign a value to the volgorde field.

I would also keep the images table more concise as in ā€˜wijzigā€™ is not neccessary because you would be removing one image in favour of another. Verwijder can be a small button on the image, volgorde can be done with a with a drag and drop, record number and filename are not relevant. Have a look at the video clip where I have shown an otherwise hidden volgorde input field.

image-sort.mp4 (855.6 KB)

1 Like

T-billy. That is very nicely done Ben. I seem to be lacking some logic sense to get things done, but trying to learn and keep up. But the way you did it as in your clip is amazingly beautiful to me. I have the form working so far, but now I am making an attempt to show preview images. Until now I managed to only get the first image in preview instead of all of them. :grin::sweat:

Now I have the multiple upload up and running I would like to preview the uploaded images. I managed to get a preview for the first one (Add an Image Preview Before Upload) but can anyone explain to me how to get a preview of all the images to be uploaded? And even better (and nicer and more efficient) how did Ben (see above movie) get it so very nice. I would love to learn how to do that.

For multiple images you just need a repeat region for them.

Haha, thought of that but as a common rule I am doing something wrong.
One image is like this: ā€œimg src=ā€" dmx-bind:src=ā€œafbeelding.files[0].dataUrlā€ width=ā€œ96ā€ dmx-show=ā€œafbeelding.valueā€"
Repeat region changed like this: ā€œdiv dmx-repeat:repeat1=ā€œafbeelding.files[0].dataUrlā€ width=ā€œ96ā€ dmx-show=ā€œafbeelding.valueā€ā€

And as you are in the meanwhile used to, not working the way I try to do it

You did not properly set it up. Your bindings point to the first record.
The repeat region expression is wrong - it must be from the data object, not from the urlā€¦

Still donā€™t get it. Which one should I select. Tried them all, but of course no joy.