I request your help in uploading multiple images/PDF files in the repeat table as below. I know how to upload & save single document by selecting the document name using Select element, however, it won’t be convenient when the list of documents to be uploaded increases.
I have this update form with upload document element. I want to be able to upload documents which are listed in the repeat table.
I went through the tutorial you shared and feel that I will have to Add new document detail eveytime to upload. It is fine when the number of documents to be uploaded is less, but will be somewhat problematic if the list of documents to be uploaded is large.
Is there a way where the list of documents is returned and document is uploaded against each item & by single click the files are uploaded & DB updated with name & path, similar to shown in the previous screenshot.
As shown in the screen shot below, there are 2 documents each having its own separate upload bar. What i am looking to achieve is, to be able to choose files for each document & then upload it upon click of Save button. Both the files/images will be saved in the folder & DB will be updated with the uploaded name & URL of the document.
Unless I’m wrong, you need to use a form repeater. You can get the number of items on your form repeater (in this case 2) by doing a query like you use on the table.
On the server connect side, the repeat will starting to upload the files one by one using the repeat action.
On the client side you will see it exactly as you have now.
One save button.
@miu I suppose your Institute table structure has the main fields/columns (e.g. institute_id, institute_name, institute_code, institute_year etc…) AND you have added a subtable to hold the documents details for each institute…
Right?
If yes, then the link that Francisco shared has all the required information.
The subtable (document details) will be handled inside a repeat in your server action.
Can you please share with us a screenshot of your table structure AND it would be nice to show us how you implemented the form of your above picture on your page (the form code or a screenshot of your from code)…
So we can understand what you have so far and if it is correct
@franse & @famousmag thanks for explaining the steps.
Yes, the table structure is same as you mentioned. I am working to implement the solution as per the doc shared by Franse & I will share the screenshots shortly.
It took time implementing the solution as I am new to development & still learning.
I followed the tutorial which works fine if I have to update text input fields. If I change the text input field with File Upload element, it uploads only 1 file & does not update the DB with filename.
Sharing the steps followed implementing the solution:
Prepared the page for update records using form repeater
I think its more clear now…
You get the main instirute info fine.
But you have to add a repeat in order to loop through your documents…
(and of course adjust the values in your database updater accordingly with the repeat values)
I am getting error while running the API (“message”: “image.load: path is required.”,) What Works: Both the images are uploaded in the correct path. What’s not working: Unable to Update the DB table
Steps for creating API:
Added Repeat & used $_POST formRepeat as the Expression
Under repeat added the remaing 4 steps
2.1) File Upload: Selected the same $_POST formRepeat for the Upload Fields.
The Step 2 - File Upload looks incorrect. Instead of selecting the formRepeat1, you need to select the uploadedDoc, which is the input field for the uploaded file.
First I supposed you have already understood that the main institute info are not updated because you update only the documents inside the repeat (I FORGOT TO TELL YOU THAT, I apologize).
For that you need an extra database update OUTSIDE the repeat (before or after the repeat, does’t matter) that will do exactly that: Update the institute main info (id, name, code, year).
Now on the files upload… EDIT: first change the file upload to what @guptast said!! Thanks @guptast! IF THIS SOLVING THE ERROR JUST IGNORE ALL THE REST
where are you getting that error message? On your browser? Can you share a screenshot?
Can you please disable only the database update step and try again? Do you still get that error?
I did the changes as suggested by @guptast, however, I am still getting image.load path is required. Out of the 2 image files I try to upload, the first file is uploaded in the folder path.
@famousmag
Ohhh, finally!!
Both the images are uploaded & saved in the folder path.
Now, I will try to update the DB table & check if it is updating properly.
Thanks my friend for helping yet again.