Upload button "title is not defined"

Hey there,

the upload button should work pretty easily:

uploadElement.startUpload()
.then(data => {
     console.log(data)
     doSomething() 
})    
.catch(uploadError => {
     console.log(uploadError)
     doSomethingElse()     
})          

The documentation supports this.

So my case is that while uploading the user can easily select a file which is not supported

  • just like this.

And if a user does that and selects a file which isn’t supported, then the upload begins, the code doesn’t enter neither .then nor .catch.

The code fails inside some Wix function which is executed along the way and it’s not sent into the catch. In the console I receive this


Going through the Stacktrace doesn’t reveal any additional info and therefore I can’t know what’s wrong.

This error BREAKS the execution of my code and anything which should happen after doesn’t.

I tried to Try Catch the entire upload section, but it breaks even the Try Catch.


So my question is - How can I easily prevent a user from uploading a wrong file-type?

Is this a mistake on the side of Wix? Did they not consider this possibility? Or is there something else going on that causes this?

.validate on the uploadElement says it’s valid, which is definitely how it shouldn’t work if the file isn’t valid.

Looks like you didn’t “close” your .then() function:

uploadElement.startUpload()
.then(data => {
     console.log(data)
     doSomething()
}) // this line was missing 
.catch(uploadError => {
     console.log(uploadError)
     doSomethingElse()     
})  

I don’t know if this is your problem, but it’s definitely an error.

Thanks, I was removing unnecessary code while posting it here on the forum and accidentally removed this, that would indeed be an error and a stupid mistake, sadly it’s not as simple a problem

So I take it the Catch should work and catch wrong file type?