Using the upload file size bindings
Hi
I am using the file manipulation 'file size' binding to display the size of a file I have uploaded on my detail pages. The only problem is that it displays as bytes e,g 1mb is displaying like 1024000.
I found this code on the net
function ByteSize($bytes)
{
$size = $bytes / 1024;
if($size < 1024)
{
$size = number_format($size, 2);
$size .= ' KB';
}
else
{
if($size / 1024 < 1024)
{
$size = number_format($size / 1024, 2);
$size .= ' MB';
}
else if ($size / 1024 / 1024 < 1024)
{
$size = number_format($size / 1024 / 1024, 2);
$size .= ' GB';
}
}
return $size;
}
// Returns '19.28mb'
print ByteSize('20211982');
I just do not know how I would combine this with my echo statement to get this to work
Your help is much appreciated