Visitors Today: 90
Total Visits: 400220

www.codester.info

Do you have source code, articles, and tutorials to share?
Visual Basic, VB.NET, C#, PHP/MySQL, C/C++, Java/JavaScript, ASP/ASP.NET, MS Access, FoxPro, SQL
You can write your own content here.

Donation


    If the information on this site helps you and you would like to make donation to XtremeXtension.com please click the LINK below.

    If you want to support us, please make a contribution. Any amount is appreciated. To make a donation via PayPal, credit card, or e-check..

    Please click the DONATE link..

    Your contribution will make XtremeXtension.com grow in the future.

Sponsor

Calendar

Smarty Modifier PHP Filesize (bytes to KB/MB)

    Posted GraniteGear Posted On March 5, 2013

    PHP 0 Current Comments 6092 Views

    Like 18 people liked this.
    You want to display the size of the file in Kb if less then 1024, in Mb if less than 1048576 etc... Here's a quick snip of code to help you easily manage your files by finding out the size/size of the file...

    SOURCE
    <?php
    function filesize($size)
    {
     $size = max(0, (int)$size);
     $units = array( 'b', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb', 'Eb', 'Zb', 'Yb');
     $power = $size > 0 ? floor(log($size, 1024)) : 0;
     return number_format($size / pow(1024, $power), 2, '.', ',') . $units[$power];
    }
    ?>





  • PHP
  • Script
Share With Your Friends
Share Your Thoughts With Other Users

Be the first to comment.

Leave a Reply
This small test serves as access restriction against malicious bots.