File size calculator

5 Years ago(Updated in 5 Years ago) PHP(Functions) 0(Disable)

File size calculator function return file size format into kb, mb or gb.

function file_size($size, $out = 'kb', $precision = 2)
    switch ($out) {
        case 'kb':
            return round($size / 1024, $precision);
        case 'mb':
            return round($size / (1024 * 1024), $precision);
        case 'gb':
            return round($size / (1024 * 1024 * 1024), $precision);
    return false;


No tag here.

Recommended pages

Change timestamp to custom format...

Use this function for change timestamp to custom format......

Human readable file size...

This function return formatting of file sizes in a human readable format. function formatFileSize( $size ) { $file_size = $size; $i = 0;   $name = array( 'byte', 'kB', 'MB', '...

Resize image function...

Resize image function for jpg format. $mood between max and min. if you choose max, this mean max size of image is $ta otherwise min size of image is $ta. function makeTheThumb( $ppath, $ta, $mood ) ...

SQL escape string function...

Escapes special characters in a string for use in an SQL statement. howewer it check get_magic_quotes_gpc function is enable or no. if true , it strips string from slashes and escaped string from spec...