I have an upload button to upload an image to form which eventually is submitted and sends data to a collection.
What I need to figure out is when the image is uploaded i need to show the image back to the user. I have only just started playing with Wix and have minimal js experience so any help gratefully received.
You can upload it and then assign it to a slider gallery or an image place holder.
Something like this:
$w('#uploadButton1').onChange(() => {
setTimeout(() => {
uploadFile();
}, 100)
})
//not sure whether or not you need a timeout here, but I put it here to be on the safe side.
function uploadFile() {
if ($w("#uploadButton1").value.length > 0) {
$w("#uploadButton1").startUpload()
.then((uploadedFile) => {
$w("#gallery1").items = [{
"type": "image",
"src": uploadedFile.url
}];
$w("#gallery1").expand();
})
.catch((uploadError) => {
console.log(`File upload error: ${uploadError.errorCode}`);
});
} else {
$w("#gallery1").collapse();
}
}