python file size
>>> import os
>>> b = os.path.getsize("/path/isa_005.mp3")
>>> b
2071611
python file size
>>> import os
>>> b = os.path.getsize("/path/isa_005.mp3")
>>> b
2071611
php get size of file
$fileSizeInBytes=filesize("/path/to/myfile.txt");
javascript file size in mb
function calc_file_size (bytes) {
if (bytes >= 1073741824) { // 1024 * 1024 * 1024
bytes = (bytes / 1073741824) + ' GB';
} else if (bytes >= 1048576) { // 1024 * 1024
bytes = (bytes / 1048576) + ' MB';
} else if (bytes >= 1024) { // 1024 * 1
bytes = (bytes / 1024) + ' KB';
} else if (bytes > 1) {
bytes = bytes + ' bytes';
} else if ($bytes == 1) {
bytes = bytes + ' byte';
} else {
bytes = '0 bytes';
}
return bytes;
}
javascrpt formatBytes
function niceBytes(x){
const units = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
let l = 0, n = parseInt(x, 10) || 0;
while(n >= 1024 && ++l){
n = n/1024;
}
return(n.toFixed(n < 10 && l > 0 ? 1 : 0) + ' ' + units[l]);
}
javascrpt formatBytes
function formatBytes(bytes, decimals = 2) {
if (bytes === 0) return '0 Bytes';
const k = 1024;
const dm = decimals < 0 ? 0 : decimals;
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us