mirror of
https://github.com/prasathmani/tinyfilemanager.git
synced 2025-01-29 20:47:45 +01:00
Fix a non well formatted numeric value encountered & Notice: Undefined offset in fm_get_filesize()
(#681)
For non `well formatted numeric value encountered`, see #670 For `Notice: Undefined offset 9` (current implementation result) see: https://3v4l.org/1qHit#v5.0.0 For new impementation result, see: https://3v4l.org/d0UBh#v5.0.0
This commit is contained in:
parent
95d41a9518
commit
08cb4b0fce
@ -2501,7 +2501,8 @@ function fm_get_filesize($size)
|
||||
{
|
||||
$size = (float) $size;
|
||||
$units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
|
||||
$power = $size > 0 ? floor(log($size, 1024)) : 0;
|
||||
$power = ($size > 0) ? floor(log($size, 1024)) : 0;
|
||||
$power = ($power > (count($units) - 1)) ? (count($units) - 1) : $power;
|
||||
return sprintf('%s %s', round($size / pow(1024, $power), 2), $units[$power]);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user