diff options
Diffstat (limited to 'application')
-rw-r--r-- | application/Utils.php | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/application/Utils.php b/application/Utils.php index 3ef2a7e2..ab463af9 100644 --- a/application/Utils.php +++ b/application/Utils.php | |||
@@ -414,23 +414,24 @@ function human_bytes($bytes) | |||
414 | $bytes /= 1024; | 414 | $bytes /= 1024; |
415 | } | 415 | } |
416 | 416 | ||
417 | return $bytes . $units[$i]; | 417 | return round($bytes) . $units[$i]; |
418 | } | 418 | } |
419 | 419 | ||
420 | /** | 420 | /** |
421 | * Try to determine max file size for uploads (POST). | 421 | * Try to determine max file size for uploads (POST). |
422 | * Returns an integer (in bytes) | 422 | * Returns an integer (in bytes) or formatted depending on $format. |
423 | * | 423 | * |
424 | * @param mixed $limitPost post_max_size PHP setting | 424 | * @param mixed $limitPost post_max_size PHP setting |
425 | * @param mixed $limitUpload upload_max_filesize PHP setting | 425 | * @param mixed $limitUpload upload_max_filesize PHP setting |
426 | * @param bool $format Format max upload size to human readable size | ||
426 | * | 427 | * |
427 | * @return int max upload file size in bytes. | 428 | * @return int|string max upload file size |
428 | */ | 429 | */ |
429 | function get_max_upload_size($limitPost, $limitUpload) | 430 | function get_max_upload_size($limitPost, $limitUpload, $format = true) |
430 | { | 431 | { |
431 | $size1 = return_bytes($limitPost); | 432 | $size1 = return_bytes($limitPost); |
432 | $size2 = return_bytes($limitUpload); | 433 | $size2 = return_bytes($limitUpload); |
433 | // Return the smaller of two: | 434 | // Return the smaller of two: |
434 | $maxsize = min($size1, $size2); | 435 | $maxsize = min($size1, $size2); |
435 | return human_bytes($maxsize); | 436 | return $format ? human_bytes($maxsize) : $maxsize; |
436 | } | 437 | } |