dataset2 is the dataset that contains user infos, reading from the userProfile database
dataset1 is the dataset that contains all the elements of the post, writing to the userPosts database
instead of linkink the button2 to dataset1 with action ‘submit’, i use the code above, and everything is fine as long as it concerns the post and _createdDate fields. But I cannot find a way to sent the image i select (via uploadButton1) to the database.
I have also tried to use:
I am still stuck at this problem. In the meanwhile i tried another approach using URLs, but it does not look to work either.
What i did is to detach the link of the image placeholder from the dataset, and use code to write the image url in the dataase.
In the ‘New Post’ lightbox i used:
to send the result of the uploadButton1 to the thumbImage placeholder image, and the thumbImage correctly dislays the image i have uploaded.
Then i use:
let toInsert = {
postCreatorId: $w('#dataset2').getCurrentItem()._id,
postCreatorImage: $w('#dataset2').getCurrentItem().profileImage,
postCreator: $w('#dataset2').getCurrentItem().fullName,
post: $w('#dataset1').getCurrentItem().post,
postImageUrl: $w('#thumbImage').src, //this is the image placeholder
_createdDate: $w('#dataset1').getCurrentItem()._createdDate,
numberOfLikes : "0"
}
wixData.insert("userPosts", toInsert)
to send all data to the database, included the image url.
The Database contains a field set as URL called postImageUrl
which is filled with this:
In the dynamic page where all posts appear (with relevant image)
i use this code: