aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/Utils.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2017-04-10 20:01:10 +0200
committerArthurHoaro <arthur@hoa.ro>2017-04-10 20:01:10 +0200
commit6a19124a0970dfd5744c4a193b5d907ba85b323e (patch)
treead886ea19ba4d38cea43ad52faf264da0383db58 /application/Utils.php
parentc8cb5c282402e3f19497ba9e57ac967a4bdefa1b (diff)
downloadShaarli-6a19124a0970dfd5744c4a193b5d907ba85b323e.tar.gz
Shaarli-6a19124a0970dfd5744c4a193b5d907ba85b323e.tar.zst
Shaarli-6a19124a0970dfd5744c4a193b5d907ba85b323e.zip
Use raw bytes for upload size hidden input
Diffstat (limited to 'application/Utils.php')
-rw-r--r--application/Utils.php11
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 */
429function get_max_upload_size($limitPost, $limitUpload) 430function 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}