Currently the code for size restriction is the following. My image size in the network and on my desktop clearly says 5.1mb, however, the log of e.target.files[0].size is 5068146, which is 4.83mb and therefore doesn't display error. I am confused about why it doesn't display an error and why the check passes. I checked other stackoverflow and interent posts and it seems that my code is correct, so I don't know where the issue is and running out of ideas. For instance: https://www.geeksforgeeks.org/validation-of-file-size-while-uploading-using-javascript-jquery/
<input
style={{ display: 'none' }}
type="file"
onChange={async e => {
if (e.target.files[0].size > 5 * 1024 * 1024) {
setImageSizeError('failure')
return
} else {
setImageSizeError('success')
}
setLoading(true)
const updatedStep = await fileUploader(e, stepId)
setLoading(false)
updateStep(updatedStep)
}}
accept=".jpg,.jpeg,.png,.pdf"
/>