I have very limited knowledge on saving and retrieving images so I am struggling with this so I hope you can assist me. I am struggling to achieve the following steps…
What I want to do:
The user will click on the “file uploader button” component to save images to his own profile.
The images will then be shown in a repeating table after file is saved.
When the image is clicked on it should be show in a second (enlarged) image component.
My apologies for the delayed reply. So yes I need help with the whole lot. The photos will be linked to vehicle’s invoice profile, the user will be able to create or update a new invoice. I have added some basic steps below that I would like to do.
Create Invoice
Add picture from file.
Save picture to backendless files.
Link picture to invoice.
Display photos in repeating table with photo component.
Display photo in full screen photo component when the photo in the repeating table is clicked.
If the delete button is clicked then the photo must be deleted from the file.
Update Invoice
Retrieve pictures linked to current invoice.
Display photos in repeating table with photo component.
I would like guidance on if I should create a file in backedless for each invoice created with photos, if yes what would the logic be for this? If no then how will i group or link photos for each invoice.
First of all, I would like to know, have you read our course on YouTube?
We also have documentation.
These resources will answer most of your questions.
Display photo in full screen photo component when the photo in the repeating table is clicked.
For this you need to have a separate block that has CSS that renders it full screen. The block will have image component stretched 100%. When the picture is clicked, you make the block visible and assign the picture URL to the image component inside of the block.
If the delete button is clicked then the photo must be deleted from the file.
Here is the block that deletes a file:
The second fault is related to resetting the file uploader on the “upload failure” logic, it is strange to me because when the first upload failed the button reset as expected but when uploading the second image the fault appears.
With regards to the expanding of the image and deleting I have done the following logic, unfortunately I am unable to test to see if the logic works…
Expand image - I have added a second image component (Full width) outside the repeating table and then use the following logic to set “fullViewPhoto” into Source URL Logic of the second image component.
Delete image/file - I am using the following logic to delete the file when the delete button is clicked.
I made a copy of testPage and called it testPageMark. I fixed the logic in my page in two places:
OnUploadSuccess - added a check to make sure the data model list exists - this is what you already do in the page initialization, but since it doesn’t run (for the reason described above), I added a workaround which you will need to remove:
As you the know none of the photos is saved to files with our current logic, but with that being said the destination file “images/jobcards” is currently empty. The logic works if its the first time I upload the image but if I refresh the page and try it again the same image it gives me the above error. What am I missing??
Thank you for your assistance. I did read the error message a couple times over but did not know that the “Overwrite Files” checkbox would fix the error.
My last question is what would be the best way to link the photos to the invoice in a database? I think the best way would be to save the links into the “photos” column in the “invoices” table, but I am not sure how to do this or if there is a better way to link photos to data to easily be retrieved later on.
If you need to associate a single database record with multiple files, I recommend using the JSON column type. In that case, you store a JSON array that would contain individual file URLs.
If you have very limited knowledge of JSON, don’t jump into our documentation first. Study JSON from the materials that focus on JSON alone. After that, here’s the Backendless documentation: https://backendless.com/docs/rest/data_json_overview.html