I want to use JavaScript with SuccessFactors to check if the size of an uploaded photo is greater than 2 MB.
I wrote the following JavaScript code, but it does not seem to be working:
if (context.files.length > 0) {
for (const i = 0; i <= context.files.length - 1; i++) {
const fsize = context.files.item(i).size;
const file = Math.round((fsize / 1024));
if (file >= 4096) {
alert("File too Big, please select a file less than 4mb");
}
}
}
You can use for of to loop through files list