I have a form where users upload an image and the image is then displayed as a preview beside the upload button before the form is submitted. The image sometimes gets uploaded and sometimes doesn't. It seems like it only works for certain images...
Here's the code:
$w('#uploadButton1').onChange(() => {
if ($w("#uploadButton1").value.length > 0) {
$w("#uploadButton1").startUpload()
.then((uploadedFile) => {
$w("#full").src = uploadedFile.url;
$w("#half").src = uploadedFile.url;
$w("#quater").src = uploadedFile.url;
$w('#image20').src = uploadedFile.url;
$w('#image30').src = uploadedFile.url;
$w('#vectorImage21').hide();
$w('#vectorImage22').hide();
$w('#fail').hide();
$w('#submit').enable();
calc();
})
.catch((uploadError) => {
console.log(`Error: ${uploadError.errorCode}`);
console.log(uploadError.errorDescription);
});
}
});
});
This post is from 2018, so being closed.
This example should suit your needs.
https://support.wix.com/en/article/wix-code-using-the-upload-button-with-code
Please add a new post to the forum if still need help.
??????????????????????
Brett Franklin can you fix it?
same issue in my form.
Is there any other way around it? I'm afraid that I have the print products and digital products under one database so it can be easier to record them in the campaigns area by differentiating them by print and digital products.
Also, I remember this problem was occurring before I connected both forms to the databases. Also, if connecting two forms to one database is the issue, then the online form would work, right? That form is connected to one database and one form. @Doron Alkalay
Anyone? @Doron Alkalay
Hi Brett!
Any chance that your upload button is connected via Dataset and uses it to insert the files into the collection? Does the code you posted is the entire code?
If not please share a link to your site so one of us, the Wix Code team, can inspect it and provide you with a solution.
Doron.
I would like this function to be more reliable. I can't understand why it works for certain files.