You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Drop a file with a size of (i.e.) 101974 bytes (= 99.58 KiB = 101.97 KB)
Look at the file size in the preview and in the error message
Expected behavior and actual behavior
The preview shows that the size of the file is 99.5 KB. That is identical to the value shown in Ms Windows file explorer.
The error message reports "File "xxxx" (101.97 KB) exceeds maximum allowed upload size of 100 KB.
I was expecting no error message to occur / both values to be the same.
When a file is selected, its size is converted into KB by dividing by 1000.
That way, the size compared to the maxFileSize property is a different one than the one displayed to the user.
The "iB" units are not frequently used by normal users and several systems (including MS Windows file explorer) calculate in Base2 (1024 bytes) but still show "KB", "MB", etc..
I would suggest to just change the calculation of the file size by changing 1000 to1024 in line 5379 in js/fileinput.js.
Fixed via the latest commit, New property bytesToKB has been introduced (and can be modified if needed) which defaults to 1024 and is used for conversion.
Prerequisites
master
branch of bootstrap-fileinput.Steps to reproduce the issue
Expected behavior and actual behavior
The preview shows that the size of the file is 99.5 KB. That is identical to the value shown in Ms Windows file explorer.
The error message reports "File "xxxx" (101.97 KB) exceeds maximum allowed upload size of 100 KB.
I was expecting no error message to occur / both values to be the same.
When a file is selected, its size is converted into KB by dividing by 1000.
bootstrap-fileinput/js/fileinput.js
Line 5379 in 1a97ee0
This value is later compared to maxFileSize, so it can be assumed that maxFileSize holds the maximum size in KB (1000 bytes), too
bootstrap-fileinput/js/fileinput.js
Line 5447 in 1a97ee0
The default method to display the size really uses KiB (1024 bytes), though.
bootstrap-fileinput/js/fileinput.js
Line 4139 in 1a97ee0
That way, the size compared to the maxFileSize property is a different one than the one displayed to the user.
The "iB" units are not frequently used by normal users and several systems (including MS Windows file explorer) calculate in Base2 (1024 bytes) but still show "KB", "MB", etc..
I would suggest to just change the calculation of the file size by changing 1000 to1024 in line 5379 in js/fileinput.js.
Environment
Browsers
Operating System
Libraries
Isolating the problem
The text was updated successfully, but these errors were encountered: