WebDeveloper.com

WebDeveloper.com (http://www.webdeveloper.com/forum/index.php)
-   PHP (http://www.webdeveloper.com/forum/forumdisplay.php?f=16)
-   -   filesize (http://www.webdeveloper.com/forum/showthread.php?t=85499)

Pixel-Artist 11-15-2005 05:37 PM

filesize
 
is there a way to display file size in kbs?

using the php filesize function of course.

LiLcRaZyFuZzY 11-15-2005 05:40 PM

PHP Code:

<?php
    $file
= "image.jpg";
    
$filesize = filesize($file);
    
    
$filesize /= 1024;
    echo
$filesize;
?>


bokeh 11-15-2005 05:48 PM

Quote:

Originally Posted by LiLcRaZyFuZzY
PHP Code:

<?php
    $file
= "image.jpg";
    
$filesize = filesize($file);
    
    
$filesize /= 1000;
    echo
$filesize;
?>


Didn't US congress declare the size of a kilobyte was 1024? Or was it Bill Gates?

jenorthar 11-15-2005 05:49 PM

Actually it should be 1024, not 1000.

Pixel-Artist 11-15-2005 05:58 PM

ok now I got another question... How do I make it round off to the hundreths place?

LiLcRaZyFuZzY 11-15-2005 06:29 PM

erm yes sorry, did too much work on SI units lately
--
http://www.php.net/round

LiLcRaZyFuZzY 11-15-2005 06:44 PM

Quote:

Originally Posted by bokeh
Didn't US congress declare the size of a kilobyte was 1024? Or was it Bill Gates?

and by the way, maybe they did..but then they did something wrong, the actual unit that represents 1024 bytes is 1 Kibibyte.

rincewind456 11-15-2005 07:05 PM

Quote:

Originally Posted by LiLcRaZyFuZzY
and by the way, maybe they did..but then they did something wrong, the actual unit that represents 1024 bytes is 1 Kibibyte.

No! originally a kilobyte was 1024 bytes, the only reason kibibyte came into existence is because storage device manufacturers have conveniently forgotten the extra 24 bytes when advertising their storage devices, therefore gulling the public into believing they were buying larger storage devices than they actually were.

http://en.wikipedia.org/wiki/Kilobyte

LiLcRaZyFuZzY 11-15-2005 07:44 PM

kilo = 1000, so even if , and i agree, 1 kilobyte = 1024 byte, it is a misuse of that prefix.

rincewind456 11-15-2005 07:50 PM

Maybe so, but that doesn't change the history of the words.

LiLcRaZyFuZzY 11-15-2005 08:05 PM

http://en.wikipedia.org/wiki/Binary_prefix
Quote:

Binary prefixes using SI symbols (Non-standard usage but common)
Quote:

In 1999, the International Electrotechnical Commission (IEC) published Amendment 2 to "IEC 60027-2: Letter symbols to be used in electrical technology – Part 2: Telecommunications and electronics". This standard, which was approved in 1998, introduced the prefixes kibi-, mebi-, gibi-, tebi-, pebi-, exbi-, to be used in specifying binary multiples of a quantity.
Quote:

The names come from the first two letters of the original SI prefixes followed by bi which is short for "binary". It also clarifies that, from the point of view of the IEC, the SI prefixes only have their base-10 meaning and never have a base-2 meaning.

NogDog 11-15-2005 10:20 PM

Use sprintf() or round() to format the output.


All times are GMT -5. The time now is 11:58 PM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.