I found this solution on this question. I want to get the image weight from a file input. On the solution, the result is brought with the MiB
(Mebibyte) unit. I wanted to know if is there some way to bring the image weight, with the same code, but on another unit, such as Megabytes.
The solution:
$('#file-input').bind('change', function() {
alert('This file size is: ' + this.files[0].size/1024/1024 + "MiB");
});
Heres an example of how I'm doing it:
$('#file-input').bind('change', function() {
alert('This file size is: ' + this.files[0].size/1024/1024 + "MiB");
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="file" name="" id="file-input">
As you can see, the unit is brought in Mebibytes. How can I change that?