Call us Toll-Free:
1-800-218-1525
Live ChatEmail us

 Sponsors

File Size

Code Wizard, 12-30-2006

Displays the file size in bytes, kilobytes, megabytes, and gigabytes depending on the size of the file.

<?php
function display_size($file){
$file_size = filesize($file);
if($file_size >= 1073741824)
{
$file_size = round($file_size / 1073741824 * 100) / 100 . "g";
}
elseif($file_size >= 1048576)
{
$file_size = round($file_size / 1048576 * 100) / 100 . "m";
}
elseif($file_size >= 1024)
{
$file_size = round($file_size / 1024 * 100) / 100 . "k";
}
else{
$file_size = $file_size . "b";
}
return $file_size;
}
?>
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

 Comments
Post your comments












Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.



About Us  |  Contact us  |  Privacy Policy  |  Terms & Conditions