bishawjit-das
11/30/2015 - 9:08 AM

Get the size of the attached file

Get the size of the attached file

filesize( get_attached_file( $attachment->ID ) );

function getSize($file){
	$bytes = filesize($file);
	$s = array('b', 'Kb', 'Mb', 'Gb');
	$e = floor(log($bytes)/log(1024));
	return sprintf('%.2f '.$s[$e], ($bytes/pow(1024, floor($e))));
}