Hey there,
To upload an image with the upload button to your database you’ll need to retrieve and store the url of the image into a global variable and then insert the url into your database.
For example:
let url; // global variable
$w("#myUploadButton").startUpload()
.then((uploadedFile) => {
let url = uploadedFile.url; // "wix:image://v1/68d3a9_1de7529c444b4c9eb38401f8efe0cad2.jpg/flowers.jpg#originWidth=1970&originHeight=1120"
})
.catch((uploadError) => {
let errCode = uploadError.errorCode; // 7751
let errDesc = uploadError.errorDescription; // "Error description"
});
export function buttonSave_click(event) {
let toInsert = {
"title": $w('#input1').value,
"description": $w("#textBox1").value,
"cover": url // url value of the image from the global variable
};
Feel free to check out the following article for reference:
Hope this was helpful! Good luck!