Improve FileHandler::returnBytes() to handle a wider range of sizes

This commit is contained in:
Kijin Sung 2016-12-17 20:49:10 +09:00
parent f313e693c4
commit d34ef5901f

View file

@ -426,11 +426,14 @@ class FileHandler
*/
public static function returnBytes($val)
{
$val = preg_replace('/[^0-9\.PTGMK]/', '', $val);
$unit = strtoupper(substr($val, -1));
$val = (float)$val;
switch ($unit)
{
case 'P': $val *= 1024;
case 'T': $val *= 1024;
case 'G': $val *= 1024;
case 'M': $val *= 1024;
case 'K': $val *= 1024;