Does .reset() on uploadButtons work properly?

@rusty I think you are trying to generate a VALIDATION, which will recognoze if the file-size is ok or not.

I tried it with ASYNC-AWAIT, but it did not work, perhaps i did an mistake…

export async function btnUP0_change(event) {
   let mySizeLimit = 100000; console.log("Size-Limit: ", mySizeLimit);
   let files = await $w("#btnUP0").value; console.log(files);
   let fileSize = await files[0].size; console.log("File-Size: ", fileSize);
   if (fileSize > mySizeLimit) {
       $w("#btnUP0").reset();
       $w("#text1").text="Selected file-size exceeded !!!";
       console.log("Selected file-size exceeded !!!");
   }
   else {$w("#text1").text="File accepted !!!"; console.log("File accepted !!!")}
}

I don’t know why the await-version did not work, but this one definetely will work…

export function btnUP0_change(event) {
   let files = $w("#btnUP0").value;    console.log(files);
   let mySizeLimit = 100000;           console.log("Size-Limit: ", mySizeLimit);
   let fileSize = files[0].size;       console.log("File-Size: ", fileSize);
   
   if (fileSize > mySizeLimit) {
        setTimeout(()=>{$w("#btnUP0").reset();},100)
        console.log("Selected file-size exceeded !!!")
   }
   else {console.log("File accepted !!!")}
}

It has a similar behaviour like with the value of inputs or dropdowns, where you need a certain delay-time, till the value is setted-up —> setTimeout(()=>{},100);

You can see the last code-version with the —> setTimeout-function in action on the following site…

https://www.media-junkie.com/multi-upload

Attention! The example, works only for the first UPLOAD-BUTTON (green one).


All the other buttons do not have this VALIDATION-function (because it is just for testing and showing you how it could work).

Just the first UPLOAD-Button do NOT-ACCEPT files bigger than —> 100KB.

Choose for example a pic which has less than 100KB and try to upload. Than choose a file that has more than 100KB and try to upload again. What happens?

And YES! What you see is my old version of a multi-uploader (workaround) :rofl:

Also, do not forget to take a look into the CONSOLE-LOGS !
Or you take a look onto the INFO-TEXT on the bottom of the example-site.