Page 1 of 1

Converting $_FILES['userfile']['size'] into Kilobyte Value?

Posted: Mon Oct 24, 2005 3:57 am
by mmc01ms
I was wondering if anybody knows how to convert the $_FILES['userfile']['size'] into a kilobyte value so I can display it on a webpage for example as 512KB.

Posted: Mon Oct 24, 2005 5:31 am
by localhost
Divide it by 1024....

Posted: Mon Oct 24, 2005 5:40 am
by mmc01ms
i know that but what is returned is for example is 119.12548 i want the first set of digits before the decimal?

Posted: Mon Oct 24, 2005 6:02 am
by Weirdan
mmc01ms wrote:i know that but what is returned is for example is 119.12548 i want the first set of digits before the decimal?
intval
floor

Posted: Mon Oct 24, 2005 6:05 am
by mmc01ms
thanks

Posted: Mon Oct 24, 2005 9:37 am
by Ralle
you could also just do as I do:

Code: Select all

$size = $size * 0.0009765625;
			$size = explode(".", $size);

Posted: Mon Oct 24, 2005 10:10 am
by foobar
Ralle wrote:

Code: Select all

$size = $size * 0.0009765625;
0.0009765625 = 1/1024

I don't really see the point of doing the division prior to putting it in the code. Seems a bit confusing to me.

Posted: Mon Oct 24, 2005 3:31 pm
by Ralle
the primary reason I posted was because of the explode thing.. it works fime for me..