Cue
October 5, 2021, 10:02pm
1
This does not work, I need to upload a single image from the live site
export function button_click(event) {
if (($w("#uploadButton").value).length > 0) {
$w("#button").label = `Uploading...'
$w("#uploadButton").uploadFiles()
.then((uploadedFiles) => {
$w("#text2").text = "Upload successful";
})
.catch((uploadError) => {
$w(“#text2 ”).text = “File upload error”;
console.log(Error: ${uploadError.errorCode}
);
console.log(uploadError.errorDescription);
});
}
else {
$w(“#text2 ”).text = “Please choose a file to upload.”;
}
}
J.D
October 5, 2021, 10:57pm
2
Go to the button property panel and check if the click function is toggled on .
The code has a little mistake on this line:
$w("#button").label = `Uploading...' //Instead of a single quotes, you used an apostrophe
Try changing it to single quotes
@chidiejike try putting a console.log() after the export function declaration to check if the button is really being pressed.
Try this:
export async function button_click(event) {
if ($w('#uploadButton').value.length > 0) {
$w('#button').label = 'Uploading...'
const upload = await $w('#uploadButton').uploadFiles()
console.log(upload)
} else {
$w('#text2').text = 'Please choose a file to upload.'
}
}
Cue
October 6, 2021, 9:26am
9
The same thing that happens in my editor, I can not even upload media to my editor, I can not even see the console.log of your code.
bwprado
October 6, 2021, 12:07pm
10
@chidiejike I just tried this code and is working perfectly.
This is the result:
[
{
"fileName": "7f7395_452a85638e09462895b8b832dc237d0c~mv2.jpg",
"fileUrl": "image://v1/7f7395_452a85638e09462895b8b832dc237d0c~mv2.jpg/600_705/7f7395_452a85638e09462895b8b832dc237d0c~mv2.jpg",
"height": 705,
"width": 600,
"originalFileName": "7f7395_452a85638e09462895b8b832dc237d0c~mv2.jpg"
}
]
Can you show us the error you are getting? Have you tried cleaning the cookies or using a different browser?
Cue
October 6, 2021, 2:44pm
11
@bwprado I do uploads on every other site, but when it comes to wix editor and my wix live site, upload does not work, even if the upload button is connected directly to a dataset and a submit button tries to submit it to a database, it still does not work.
I’m sorry mate, I really don’t know how to help you, it is working just fine here.