Hey,
Ok I've searched the forum, can't seem to find any answers.
I've got a fileupload facility that uploads fine etc and gets the filesize properly.
Now, is there anyway to format this so it's more friendly. For example, if I have I have a file that is 2257141 bytes and I want to output the filesize, I'm currently using the following:
$size = round($filesize / 1024,0);
Now, this gives me something like 2204 KB but as this is over 1000KB, I'd like to round it again so that it's more like 2.2MB. Is there an easy way to do this?
One other thing, I've got a function that gives an estimate on download time:
function download_timer ($file, $connection)
{
$time_secs = $file / $connection;
$time_mins = $time_secs / 60;
return $time_mins;
}
$size = $row->size * 1024;
$speeds = array('56','640','1500');
while (list(, $speed) = each($speeds))
{
echo '<br>On ' . $speed . 'K: ' . download_timer($size,$speed);
}
Now, again for example if I have a file that is 2257141 bytes it gives me things like this;
On 56K: 671.69523809524
On 640K: 58.773333333333
On 1500K: 25.076622222222
Any way to round these to the nearest 10, if you know what I mean? So 56K would be 672, 640K would be 59 etc...
Also, as 56K is more than 2 numbers long, could I then round it so it becomes 7 minutes?
Any help would be greatly appreciated.
Cheers,
Chris