When using a Submit Button in a form, the image is stored perfectly in the collection image field by just connecting the Upload Button to the dataset image field.
For certain reasons, I need to code the Insert. I have the same upload button with the same connection. The below code just store the filename uploaded by the user. I need to store the image itself.
let toInsert = {
“image1”: $w(“#uploadButton1”).value,
}
wixData.save(“sellers”, toInsert)
Hi,
I recommend checking out this article about How to Use the Upload Button with Code.
After using the startUpload function, it returns an object with a url field of the image uploaded:
@christopher-derrell Hi Chris, i have added / changed the code. There are no errors but the image i’m uploading is not finding its way into the collection ?
A related question: I cannot simply use a URL field in a form to enter an image URL in an image field in a datasource, although with the datasource manager I can manually enter a URL in an image field.
Can I instead use an event trigger on the form submit button to grab an image URL that is entered in a text field and insert it by code as an image URL in a datasource image field? I’m interested in having data entered using provided image URLs from a central image CDN, rather than the data entry operator uploading actual images.
Thanks for your insights about this approach.