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.