Hi there, I am working on a member’s profile update page that allows them to update their details and also upload images that are then used in a gallery on their public profile page. I can’t seem to get the images to upload in my image database from a user input option.
I have 2 databases - 1 image database and 1 for the profile information. This is because I wanted to have a gallery of images per member and this was the suggested way to do this.
It sounds like it should be possible to implement.
How did you try to implement it?
Can you please share a link to the discussed page so i can check out your configuration?
First of all, you have to connect the image upload button and the save button to the ExhibitorImages dataset:
Change the ExhibitorImages dataset’s mode to Read & Write
Connect the upload button to the correct image field of that dataset
Connect the save image’s button “link” property to the “Submit” action
Now your users should be able to upload images to the ExhibitorImages collection.
Please note that images have to be uploaded one by one.
Lastly, you have to make sure that the uploaded images are linked to the current user.
Something like this should work:
Oh, my bad, actually since we set the dataset to Read & Write mode, we’re always editing the first image instead of adding new ones…
I think the easiest solution to that is adding another dataset, so that the current dataset will be in Read Only mode and will only be connected to the gallery, and a new dataset with Write Only mode will be responsible for adding new images. Since it’s Write Only, it will only add new images and not edit existing ones…
Also, whenever a new image is added using the second dataset, we would like to refresh the first dataset so the new image will show… something like that:
OK thanks, I have updated the current dataset to be Read Only and created a new dataset to Write only. Now the image has loaded into the new database which is great. Now how do I do the next part which is to get the new image into the gallery once they have uploaded it? With the code you have given me do I need to change any of it to reflect the dataset names?
I have created a form with text inputs and an image upload button.
I wanted to use Wix Code to insert both text and image file into the database.
How should I go about doing it?
I have tried to upload the image after the text input data has been uploaded. But the images get updated in the previous database entry and not the new one that was inserted.
Anna, just make sure to add the code somewhere inside your onReady function.
Regarding dataset names, the purpose of the code is to make sure that whenever a user uploads and saves a new image ( onAfterSave ), the dataset that is connected to the gallery should refresh in order to display the newly added image. So match the names accordingly.
Ben, if you use a dataset and connect it to the upload button, you don’t have to worry about any of that, all is taken care of for you. You can just connect the upload button, all the text inputs and a submit button to the dataset.
If you’re sure you want to do it manually, check out this article Velo Tutorial: Using the Upload Button with Code | Help Center | Wix.com
The reason why I want to use Wix Code is because I have a few auto-fill inputs. I have tried to link these auto-fill inputs to the database, but they appear as blanks.
You can link auto-fill inputs (e.g. name) from your Members database and add other user input fields. Then use setFieldValue function to submit auto-fill inputs to your database.