Fix setting the max-upload-size for really large values.
php can only parse filesize units up to gigabytes, not terabytes or petabytes.
This commit is contained in:
parent
6d378515f8
commit
7cdb16979a
|
@ -280,9 +280,7 @@ class OC_Files {
|
||||||
return false;
|
return false;
|
||||||
$size -= 1;
|
$size -= 1;
|
||||||
} else {
|
} else {
|
||||||
$size = OC_Helper::humanFileSize($size);
|
$size = OC_Helper::phpFileSize($size);
|
||||||
$size = substr($size, 0, -1); //strip the B
|
|
||||||
$size = str_replace(' ', '', $size); //remove the space between the size and the postfix
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//don't allow user to break his config -- broken or malicious size input
|
//don't allow user to break his config -- broken or malicious size input
|
||||||
|
|
|
@ -305,6 +305,32 @@ class OC_Helper {
|
||||||
return "$bytes PB";
|
return "$bytes PB";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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
|
* @brief Make a computer file size
|
||||||
* @param string $str file size in human readable format
|
* @param string $str file size in human readable format
|
||||||
|
|
Loading…
Reference in New Issue