1
0
Fork 0

show maximagesize warning in a human readable format

This commit is contained in:
rabuzarus 2015-06-29 02:39:08 +02:00
commit a982320ba9
5 changed files with 17 additions and 5 deletions

View file

@ -1013,3 +1013,15 @@ function store_photo($a, $uid, $imagedata = "", $url = "") {
return($image);
}
function formatBytes($bytes, $precision = 2) {
$units = array('B', 'KB', 'MB', 'GB', 'TB');
$bytes = max($bytes, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
$pow = min($pow, count($units) - 1);
$bytes /= pow(1024, $pow);
return round($bytes, $precision) . ' ' . $units[$pow];
}