Navigation :
HomeSource code
Tutorials
RSS feeds
Articles
Wordpress plugins
Blog
Books
Software
Downloads
Hosting
manuals
Script directory
Training
Our Links
Site Sponsors :
Bookmark :
Links :
software directorydomain names
programmershelp
Downloads :
Misc :
Webmaster ResourcesOnly PHP
ScriptSearch.com
Scripts.com - Get the best scripts NOW!
AndreaPHP Programming
File size function
This example shows how to format a file and present its size better
<?php
function format_size ($file)
{
//find the filesize of the file
$get_file_size = filesize($file);
//if the filesize has between 7 an 9 characters then its in Mb
if (strlen($get_file_size) <= 9 && strlen($get_file_size) >= 7)
{
$get_file_size = number_format($get_file_size / 1048576,1);
return "$get_file_size MB";
}
//10 characters or over means Gb
elseif (strlen($get_file_size) >= 10)
{
$get_file_size = number_format($get_file_size / 1073741824,1);
return "$get_file_size GB";
}
//anything else is kilobytes
else
{
$get_file_size = number_format($get_file_size / 1024,1);
return "$get_file_size KB";
}
}
?>
<?php
echo format_size("index.htm");
echo "<br>";
echo format_size("monthimages.zip");
echo "<br>";
echo format_size("sampledb.mdb");
?>
Books :
Sponsors :
Random Code :
Random passwords(randomizing)simple quote of the month(application)
hexadecimal to decimal conversion(math)
Random Article :
PHP General ScriptingNetwork:
Programming resourcesTutorials directory
Clickbank mall
sell software
Free auctions, low cost stores
UK products
US products
Gambling directory
Sexy free wallpapers
Hosting resources
ASP site
DVD site
Domain names
Dating site
Software directory
Maxi directory
bigarticle : free articles
Del.icio.us
Digg
Furl
Newsvine
Netscape
Reddit
StumbleUpon
Technorati
Squidoo
Windows Live
Yahoo MyWeb
Ask
Google