Display filesize of custom field value

function to handle to show file size i.e.

paste this code in functions.php

   /*
 * @param string $fileSize Filepath
 * @param int $digits Digits to display
 * @return string|bool Size (KB, MB, GB, TB) or boolean
 */

function getFilesize($fileSize, $digits=2) {
    $sizes = array("TB","GB","MB","KB","B");
    $total = count($sizes);
    while ($total-- && $fileSize > 1024) {
        $fileSize /= 1024;
    }
return round($fileSize, $digits)." ".$sizes[$total];
}

paste this code in single.php

if($kpmFile !== get_post_custom_values("kpm_UploadFile")) {
$head = array_change_key_case(get_headers("http://example.net/publications/Wellspring-of-Hope.pdf", TRUE));
echo $filesize = getFilesize($head['content-length']);
}

tech