This code prints out “b” for bytes, “m” for megs, etc depending on the file size.

= 1073741824) {
		$fileweight = round($fileweight / 1073741824 * 100) / 100 . "GB";
	} elseif ($fileweight >= 1048576) {
		$fileweight = round($fileweight / 1048576 * 100) / 100 . "MG";
	} elseif ($fileweight >= 1024) {
		$fileweight = round($fileweight / 1024 * 100) / 100 . "k";
	} else {
		$fileweight = $fileweight . "b";
	}
	return $fileweight;
} // end function
?> 

Advertisement

468x60_makemoney

Advertisement

Themeforest
Previous post

Truncate text to x number of words

Next post

Sending HTML/Plain Text Mail Simultaneously using PHP

snipe

snipe

I’m a tech geek/dev/infosec-nerd/scuba diver/blacksmith/sword-fighter/crime fighter/ENTP/warcrafter/activist. I'm the CTO at Mass Mosaic and the CEO of Grokability, Inc. in San Diego, CA. Tweet at me @snipeyhead or read more...