Insert Record with images

I need guidance, i am trying to insert some records which include multiple images to be written to the database and saved in a folder. I need to know the serverconnect order (conn>>file upload>>insert), the current was successfully submitted, but all fields were NULL. Thanks

![2|365x326](uploa d://2JuDqDaAgUJOgNu4GaCzI7oyaDD. png)

Have a look at

and

Thank you sir.

1 Like

Hello Ben, referencing your video (https://www.youtube.com/watch?v=ZIOJdbfxZdI, titled: reating a blog with Wappler Part 2 - Creating a new user). If you are going to modify the DB and add 2-3 images of the new user, what is the format going to look like. Thanks.

Thank you for your compliment, but the author is Brian English (@Hyperbytes). If he is not too busy (read: lazing about), he will be here soon.

2 Likes

@ben, you woke me up :innocent:

My recommendation for the optimal solution would be to use two tables.
Firstly the user would be in one table with a unique user ID as a primary key
A second table would hold the image details with a foreign key matching the users primary key

Assuming the user is uploading their own images

So you would have something like:

USER TABLE
Userid
UserName

IMAGE TABLE
Imageid
Imagename
Userid

So you would retrieve the userid from the securityprovidername.identity

Then in the upload you would use a repeat to loop through the uploaded images and insert them into the table as separate entries setting the userid to securityprovideranme.identity to link the image to the user.

2 Likes

Awesome response and sorry for waking you up.
So a single form cannot do the magic…

Use use a multi file upload (dropzone is great for that) and you can add the images at the same time. One form, one button but multi image upload.

Yes I use the dropzone element with the image.
In my server action, i simply have
DBconn>>Insert::fileUpload…the record was inserted but NULL on the image…
at the fileUpload level, is the repeat required?

if you have the dropzone set to multi file (check for square brackets after the field name) something like

files[]

then it will be sent as a array and you will have to repeat through it to get the values, if a single image upload it is not necessary to have a repeat

Thanks, will try that as soon as I get back.

Just a question Ben. If I have 500 - 800 images… and want to upload them this way… will it do it…??? will it loop with the repeat region … .one by one… so the POST value does not exceed this

Personally I would upload in smaller batches. The uploads can take a long time and if you leave the page that your upload form is on the upload will fail.

1 Like

cool thanks for all these tips… makes sense… its all going to come down to “common” sense on the clients behalf… but as you know they want to do it in one go… :slight_smile: :slight_smile: