/    Sign up×
Community /Pin to ProfileBookmark

is there a way to display file size in kbs?

using the php filesize function of course.

to post a comment
PHP

11 Comments(s)

Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYNov 15.2005 — [code=php]
<?php
$file = "image.jpg";
$filesize = filesize($file);

$filesize /= 1024;
echo $filesize;
?>
[/code]
Copy linkTweet thisAlerts:
@bokehNov 15.2005 — [code=php]
<?php
$file = "image.jpg";
$filesize = filesize($file);

$filesize /= 1000;
echo $filesize;
?>
[/code]
[/QUOTE]
Didn't US congress declare the size of a kilobyte was 1024? Or was it Bill Gates?
Copy linkTweet thisAlerts:
@jenortharNov 15.2005 — Actually it should be 1024, not 1000.
Copy linkTweet thisAlerts:
@Pixel-ArtistauthorNov 15.2005 — ok now I got another question... How do I make it round off to the hundreths place?
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYNov 15.2005 — 

erm yes sorry, did too much work on SI units lately
--


http://www.php.net/round
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYNov 15.2005 — Didn't US congress declare the size of a kilobyte was 1024? Or was it Bill Gates?[/QUOTE]
and by the way, maybe they did..but then they did something wrong, the actual unit that represents 1024 bytes is 1 [url=http://en.wikipedia.org/wiki/Kibibyte]Kibibyte[/url].
Copy linkTweet thisAlerts:
@rincewind456Nov 16.2005 — and by the way, maybe they did..but then they did something wrong, the actual unit that represents 1024 bytes is 1 [url=http://en.wikipedia.org/wiki/Kibibyte]Kibibyte[/url].[/QUOTE]

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
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYNov 16.2005 — kilo = 1000, so even if , and i agree, 1 kilobyte = 1024 byte, it is a misuse of that prefix.
Copy linkTweet thisAlerts:
@rincewind456Nov 16.2005 — Maybe so, but that doesn't change the history of the words.
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYNov 16.2005 — http://en.wikipedia.org/wiki/Binary_prefix
Binary prefixes using SI symbols ([B]Non-standard usage[/B] 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". [B]This standard, which was approved in 1998[/B], 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, [B]the SI prefixes only have their base-10 meaning and never have a base-2 meaning[/B].[/QUOTE]
Copy linkTweet thisAlerts:
@NogDogNov 16.2005 — Use [url=http://www.php.net/sprintf]sprintf()[/url] or [url=http://www.php.net/round]round()[/url] to format the output.
×

Success!

Help @Pixel-Artist spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...