How to upload multiple documents in repeat table

Glad it worked

Anything you need drop it here

Glad it is working now.

Thanks @guptast for your help.

1 Like

Hey @famousmag @franse @guptast

With your help I am able to get the files uploaded in the folder & also update the DB.
This is the final server action:

The problem that I have run into is, if i have to update any single file & if I choose a single file for upload, then only that file gets uploaded while deleting the other file in the folder. Also, the server action gives an error: image.load path not found.

Is there a way, to be able to upload a single file without been deleting the other file & also update the DB with the path to the new uploaded file?

Hi AJ,

This part of your question is unclear. Which is the other file in the folder? Does it happen when the new file being uploaded has the same name as the file already saved in the folder/DB?

Can you show us the query_docName fields and condition?

1 Like

Also can you check on your File Upload if overwrite option is selected?
image

I have followed the, ‘Using App Connect Form Repeater with Update Record Forms’ tutorial for uploading the images.
The form is shown below:
In the repeat region (Upload Documents section) , there are 2 images which are to be uploaded. Currently, i can upload both the images simultaneously. However, if i try to upload any of the single image later, it gets uploaded but deletes the other image which was not selected for upload & the server connect returns error:

image.load: path is required.

query_docName fields & condition

image

Condition:

No, the Overwrite option is not selected in the File Upload.

I have selected that option in the Save Image step.
image

You are checking whether the [$index] from the formRepeat is matching with the DocID. The $index will always start from 0 and will increment up to the total number of files when you run the upload API. So, if DocID matches with the $index value, it will delete that file.

You can use guid in the File Upload -> Template field to give the uploaded files a unique ID. The template for this can be like this {{docname}}_{guid}{ext}. You can only type in this field. {{docname}} can be replaced with a field you are sending from the frontend.

You mean that in your documents repeat:

File A (red) is defined (“Choose file” and click upload)
and what about File B (green)?
You have deleted this line (clicked the red “Del” button) before click submit (Save button) or it’s input fields are empty?

Anyway there must be a mismatch in how many files you upload because the api is looking for a second file when there isn’t a second file.
But again… are you handling the $_POST.files to match the existing number of files in database?
If database have 2 files (like the picture and you delete the one thjis should be handled in your repeat.
Or maybe deleted the 2nd one that existed in database and uploaded another one…
You have to ckeck these cases…

I hope you understand what I mean…

Thank You guys for your support.
I tweaked the approach a little bit & got it working.
Your inputs helped understanding the logic tremendously. :slightly_smiling_face:

4 Likes