PDA

View Full Version : byte to megabyte


weronpc
07-22-2003, 02:20 AM
In my uploading script.
$_FILES['userfile']['size'] is in bytes, how can I convert it to megabytes?

I can't find it anywhere in php.net

Thank you all

Spookster
07-22-2003, 02:21 AM
Well there are 1024 kilobytes in a megabyte. Just do the math.

weronpc
07-22-2003, 02:32 AM
hehehe... I should thought of that..

thanx..

also, is there a function that allow me format numbers?

eg, change 12345 to 12,345

Spookster
07-22-2003, 03:43 AM
Originally posted by weronpc
hehehe... I should thought of that..

thanx..

also, is there a function that allow me format numbers?

eg, change 12345 to 12,345

http://us4.php.net/manual/en/function.number-format.php

STDestiny
07-24-2003, 12:21 AM
Originally posted by Spookster
Well there are 1024 bytes in a megabyte. Just do the math.

Actually, there are 1024 bytes in a kilobyte and 1024 kilobytes in a megabyte. (iow, 1,048,576 bytes in one mega byte)

-Andrew

Spookster
07-24-2003, 01:00 AM
Originally posted by STDestiny
Actually, there are 1024 bytes in a kilobyte and 1024 kilobytes in a megabyte. (iow, 1,048,576 bytes in one mega byte)

-Andrew

Good catch. :thumbsup: I was thinking kilobytes and typed bytes.