diff options
author | Morris Jobke <hey@morrisjobke.de> | 2014-05-03 11:49:38 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2014-05-03 11:49:38 +0200 |
commit | 623161b9a92dacc54ce198e9f762c8760b73ca00 (patch) | |
tree | fec399a54168cfe7414d8ea591868a9600059bb4 /lib/private/helper.php | |
parent | cf20de185c95847810e6d0423d67f5bbc6506c2d (diff) | |
parent | 1245ff8f318fafd66eed1ba8f9f2b3755aa537ca (diff) | |
download | nextcloud-server-623161b9a92dacc54ce198e9f762c8760b73ca00.tar.gz nextcloud-server-623161b9a92dacc54ce198e9f762c8760b73ca00.zip |
Merge pull request #8023 from flyser/master
Fix setting the max-upload-size for really large values.
Diffstat (limited to 'lib/private/helper.php')
-rw-r--r-- | lib/private/helper.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/private/helper.php b/lib/private/helper.php index ab1e0d38924..4058ec199a7 100644 --- a/lib/private/helper.php +++ b/lib/private/helper.php @@ -306,6 +306,32 @@ class OC_Helper { } /** + * @brief Make a php file size + * @param int $bytes file size in bytes + * @return string a php parseable file size + * + * Makes 2048 to 2k and 2^41 to 2048G + */ + public static function phpFileSize($bytes) { + if ($bytes < 0) { + return "?"; + } + if ($bytes < 1024) { + return $bytes . "B"; + } + $bytes = round($bytes / 1024, 1); + if ($bytes < 1024) { + return $bytes . "K"; + } + $bytes = round($bytes / 1024, 1); + if ($bytes < 1024) { + return $bytes . "M"; + } + $bytes = round($bytes / 1024, 1); + return $bytes . "G"; + } + + /** * @brief Make a computer file size * @param string $str file size in human readable format * @return int a file size in bytes |