Hey there, great question. If you’re receiving the images using the File Upload Button, you can actually validate/block the uploads that are over a certain size, before they happen.
So for example, you could:
-
Check if they’re on mobile
-
Check the File Size once a file has been selected (using the onChange ())
-
Check the size of the file they’ve selected, before you startUpload().
You can do the third step with code like this:
/**
* Adds an event handler that runs when an input element's value
is changed.
* @param {$w.Event} event
*/
export function uploadButton1_change(event) {
console.log(event);
if(wixWindow.formFactor === "Mobile"){
const fileSizeInBytes = event.target.value[0].size;
//You can use the number 2097152 to equal 2 MB.
if(fileSizeInBytes > 2097152){
//This is where you can write code to show a message to them.
}
}
}
Let me know if this helps along the lines of what you’re aiming to achieve.