Save original Image and Create Thumbnail Image

I have a half working Server Action - it’s for a Multiple image upload form.
I can upload the original images and have the folders created for both the original and the thumbnail.

It all works if I upload one image at a time. It will upload both original and thumb.

When I try to upload multiple images, only the original images upload correctly and insert in the db fine.

But as for the thumbnails, only one image get created and upload, and three of the same file names are added to the DB.

I am nearly there, I just can’t get the logic/order right - I just want for every original file and thumbnail also gets created and its filepath will updated in the same record as the original file, as something like thumb_filepath.

I did try putting it under the Repeat step but that didn’t work either.

Here I upload the images to a temporary folder, create the main images and thumbnails. Then enter the info into the database and delete the temporary folder.

image

thanks @ben will this support Multiple file upload. I have a Dropzone on the app side form so I can drop in multiple files as once.

This is an old playlist, but may help. The first video is the server side and the second is client side.

1 Like

Thanks Ben. Will do.