Return to Snippet

Revision: 23958
at February 17, 2010 10:31 by ReeceMarsland


Initial Code
function get_file_size($file_size) {
	$range = 0;

	$size[0] = 'bytes';
	$size[1] = 'kb';
	$size[2] = 'mb';
	$size[4] = 'gb';
	$size[5] = 'tb';

	while($file_size>1024){
		$file_size = $file_size / 1024;
		$range++;
	}

	$file_size = round($file_size, 2);
	return $file_size.' '.$size[$range];
}

Initial URL

                                

Initial Description

                                

Initial Title
Calculate file size with range i.e bytes, kb, mb, gb

Initial Tags
php, files

Initial Language
PHP