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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mmc01ms
Forum Commoner
Posts: 97
Joined: Wed Dec 01, 2004 3:33 am
Location: Nottingham, UK

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

Post 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.
localhost
Forum Commoner
Posts: 43
Joined: Tue Dec 07, 2004 4:52 am
Location: islamabad
Contact:

Post by localhost »

Divide it by 1024....
mmc01ms
Forum Commoner
Posts: 97
Joined: Wed Dec 01, 2004 3:33 am
Location: Nottingham, UK

Post 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?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post 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
mmc01ms
Forum Commoner
Posts: 97
Joined: Wed Dec 01, 2004 3:33 am
Location: Nottingham, UK

Post by mmc01ms »

thanks
Ralle
Forum Commoner
Posts: 38
Joined: Mon Oct 17, 2005 5:05 am

Post by Ralle »

you could also just do as I do:

Code: Select all

$size = $size * 0.0009765625;
			$size = explode(".", $size);
foobar
Forum Regular
Posts: 613
Joined: Wed Sep 28, 2005 10:08 am

Post 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.
Ralle
Forum Commoner
Posts: 38
Joined: Mon Oct 17, 2005 5:05 am

Post by Ralle »

the primary reason I posted was because of the explode thing.. it works fime for me..
Post Reply