Merge pull request #1703 from rabuzarus/readable_bytes
show maximagesize warning in a human readable format
This commit is contained in:
commit
17514e0d68
6 changed files with 18 additions and 5 deletions
|
|
@ -1013,3 +1013,4 @@ function store_photo($a, $uid, $imagedata = "", $url = "") {
|
|||
|
||||
return($image);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2282,3 +2282,15 @@ function deindent($text, $chr="[\t ]", $count=NULL) {
|
|||
|
||||
return implode("\n", $lines);
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue