Created
September 28, 2017 10:39
-
-
Save Krknv/b0b01b262304a911a3c4d4bbd6a9e5fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// PHP filesize MB/KB conversion | |
function filesize_formatted($path) | |
{ | |
$size = filesize($path); | |
$units = array( 'B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); | |
$power = $size > 0 ? floor(log($size, 1024)) : 0; | |
return number_format($size / pow(1024, $power), 2, '.', ',') . ' ' . $units[$power]; | |
} | |
// https://stackoverflow.com/questions/5501427/php-filesize-mb-kb-conversion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment