Better handling of max file upload size according to PHP settings

- Allow unlimited size
- Better parsing of PHP size

Fixes #4896
This commit is contained in:
Frédéric Guillot
2023-03-02 20:24:12 -08:00
committed by Frédéric Guillot
parent 6e84f41517
commit b138a99ce3
11 changed files with 56 additions and 31 deletions

View File

@@ -71,29 +71,6 @@ class TextHelper extends Base
return round(pow(1024, $base - floor($base)), $precision).$suffixes[(int)floor($base)];
}
/**
* Get the number of bytes from PHP size
*
* @param integer $val PHP size (example: 2M)
* @return integer
*/
public function phpToBytes($val)
{
$size = (int) substr($val, 0, -1);
$last = strtolower(substr($val, -1));
switch ($last) {
case 'g':
$size *= 1024;
case 'm':
$size *= 1024;
case 'k':
$size *= 1024;
}
return $size;
}
/**
* Return true if needle is contained in the haystack
*