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
mmc01ms
Forum Commoner
Posts: 97 Joined: Wed Dec 01, 2004 3:33 am
Location: Nottingham, UK
Post
by mmc01ms » Mon Oct 24, 2005 3:57 am
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 » Mon Oct 24, 2005 5:31 am
Divide it by 1024....
mmc01ms
Forum Commoner
Posts: 97 Joined: Wed Dec 01, 2004 3:33 am
Location: Nottingham, UK
Post
by mmc01ms » Mon Oct 24, 2005 5:40 am
i know that but what is returned is for example is 119.12548 i want the first set of digits before the decimal?
Weirdan
Moderator
Posts: 5978 Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine
Post
by Weirdan » Mon Oct 24, 2005 6:02 am
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 » Mon Oct 24, 2005 6:05 am
thanks
Ralle
Forum Commoner
Posts: 38 Joined: Mon Oct 17, 2005 5:05 am
Post
by Ralle » Mon Oct 24, 2005 9:37 am
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 » Mon Oct 24, 2005 10:10 am
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 » Mon Oct 24, 2005 3:31 pm
the primary reason I posted was because of the explode thing.. it works fime for me..