upload-limit v0.2 solved uploadLimitFormate issues , add helper for format_megabytes

This commit is contained in:
Milos Holba
2020-11-07 15:19:03 +01:00
committed by Peter Papp
parent 966145d384
commit 8b8dc34ba6
8 changed files with 32 additions and 8 deletions

View File

@@ -355,6 +355,23 @@ function format_gigabytes($gigabytes)
}
}
/**
* Format string to formated megabytes string
*
* @param $megabytes
* @return string
*/
function format_megabytes($megabytes)
{
if ($megabytes >= 1000) {
return $megabytes / 1000 . 'GB';
} else if ($megabytes >= 1000000) {
return $megabytes / 1000000 . 'TB';
}else {
return $megabytes . 'MB';
}
}
/**
* Convert megabytes to bytes
*