What measuring unit is used for file sizes in javascript?

Your question is not about JavaScript itself, but the File API.

See the documentation for File. It doesn't list the size property but it does say:

The File interface also inherits properties from the Blob interface

So see the documentation for Blob:

Blob.size Read only The size, in bytes, of the data contained in the Blob object.

Thus the value is given in bytes.


The file size is measured in bytes - do this:

if (s > 4 * 1024 * 1024)
    alert("Too big");

Tags:

Javascript