How do I solve this, the upload button code does not work on my site

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.”;
}
}

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

Yes it is

Still does not work

@chidiejike try putting a console.log() after the export function declaration to check if the button is really being pressed.

@bwprado It is

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.'
    }
}

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.

@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?

@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.