Skip to content

Instantly share code, notes, and snippets.

@Octagon-simon
Last active July 19, 2022 07:46
Show Gist options
  • Select an option

  • Save Octagon-simon/09c72a940e9ac943038dda7af4787254 to your computer and use it in GitHub Desktop.

Select an option

Save Octagon-simon/09c72a940e9ac943038dda7af4787254 to your computer and use it in GitHub Desktop.
//convert 2mb to bytes
const requiredSize = 1024 * 1024 * 2;
//save file size
let filesSize = 0;
//loop through object
for (let file of fileInpFiles){
//add up file sizes
filesSize+=file.size;
}
//check if files size is greater than 2MB or 2,000,000 bytes
if(filesSize > requiredSize){
console.log("Files must not exceed 2MB in size");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment