system/modules/DocumentManagementSystem/classes/pojos/Document.php
public static function convertFileSize($doubleFileSize, $strSourceUnit, $strTargetUnit)
	{
		if ($strSourceUnit == $strTargetUnit)
		{
			// no conversion needed
			return $doubleFileSize;
		}
		
		if ($strSourceUnit == \Document::FILE_SIZE_UNIT_BYTE)
		{
			switch ($strTargetUnit)
			{
				case \Document::FILE_SIZE_UNIT_KB : return $doubleFileSize / 1024;
				case \Document::FILE_SIZE_UNIT_MB : return $doubleFileSize / 1024 / 1024;
				case \Document::FILE_SIZE_UNIT_GB : return $doubleFileSize / 1024 / 1024 / 1024;
			}
		}
		else if ($strSourceUnit == \Document::FILE_SIZE_UNIT_KB)
		{
			switch ($strTargetUnit)
			{
				case \Document::FILE_SIZE_UNIT_BYTE : return $doubleFileSize * 1024;
				case \Document::FILE_SIZE_UNIT_MB   : return $doubleFileSize / 1024;
				case \Document::FILE_SIZE_UNIT_GB   : return $doubleFileSize / 1024 / 1024;
			}
		}
		else if ($strSourceUnit == \Document::FILE_SIZE_UNIT_MB)
		{
			switch ($strTargetUnit)
			{
				case \Document::FILE_SIZE_UNIT_BYTE : return $doubleFileSize * 1024 * 1024;
				case \Document::FILE_SIZE_UNIT_KB   : return $doubleFileSize * 1024;
				case \Document::FILE_SIZE_UNIT_GB   : return $doubleFileSize / 1024;
			}
		}
		else if ($strSourceUnit == \Document::FILE_SIZE_UNIT_GB)
		{
			switch ($strTargetUnit)
			{
				case \Document::FILE_SIZE_UNIT_BYTE : return $doubleFileSize * 1024 * 1024 * 1024;
				case \Document::FILE_SIZE_UNIT_KB   : return $doubleFileSize * 1024 * 1024;
				case \Document::FILE_SIZE_UNIT_MB   : return $doubleFileSize * 1024;
			}
		}
		// no match
		return -1;
	}
public static function convertFileSize($doubleFileSize, $strSourceUnit, $strTargetUnit)
	{
		if ($strSourceUnit == $strTargetUnit)
		{
			// no conversion needed
			return $doubleFileSize;
		}
		
		if ($strSourceUnit == \Document::FILE_SIZE_UNIT_BYTE)
		{
			switch ($strTargetUnit)
			{
				case \Document::FILE_SIZE_UNIT_KB : return $doubleFileSize / 1024;
				case \Document::FILE_SIZE_UNIT_MB : return $doubleFileSize / 1024 / 1024;
				case \Document::FILE_SIZE_UNIT_GB : return $doubleFileSize / 1024 / 1024 / 1024;
			}
		}
		else if ($strSourceUnit == \Document::FILE_SIZE_UNIT_KB)
		{
			switch ($strTargetUnit)
			{
				case \Document::FILE_SIZE_UNIT_BYTE : return $doubleFileSize * 1024;
				case \Document::FILE_SIZE_UNIT_MB   : return $doubleFileSize / 1024;
				case \Document::FILE_SIZE_UNIT_GB   : return $doubleFileSize / 1024 / 1024;
			}
		}
		else if ($strSourceUnit == \Document::FILE_SIZE_UNIT_MB)
		{
			switch ($strTargetUnit)
			{
				case \Document::FILE_SIZE_UNIT_BYTE : return $doubleFileSize * 1024 * 1024;
				case \Document::FILE_SIZE_UNIT_KB   : return $doubleFileSize * 1024;
				case \Document::FILE_SIZE_UNIT_GB   : return $doubleFileSize / 1024;
			}
		}
		else if ($strSourceUnit == \Document::FILE_SIZE_UNIT_GB)
		{
			switch ($strTargetUnit)
			{
				case \Document::FILE_SIZE_UNIT_BYTE : return $doubleFileSize * 1024 * 1024 * 1024;
				case \Document::FILE_SIZE_UNIT_KB   : return $doubleFileSize * 1024 * 1024;
				case \Document::FILE_SIZE_UNIT_MB   : return $doubleFileSize * 1024;
			}
		}
		// no match
		return -1;
	}
public static function convertFileSize ( $ doubleFileSize , $ strSourceUnit , $ strTargetUnit ) { if ( $ strSourceUnit == $ strTargetUnit ) { // no conversion needed return $ doubleFileSize ; } if ( $ strSourceUnit == \ Document :: FILE_SIZE_UNIT_BYTE ) { switch ( $ strTargetUnit ) { case \ Document :: FILE_SIZE_UNIT_KB : return $ doubleFileSize / 1024 ; case \ Document :: FILE_SIZE_UNIT_MB : return $ doubleFileSize / 1024 / 1024 ; case \ Document :: FILE_SIZE_UNIT_GB : return $ doubleFileSize / 1024 / 1024 / 1024 ; } } else if ( $ strSourceUnit == \ Document :: FILE_SIZE_UNIT_KB ) { switch ( $ strTargetUnit ) { case \ Document :: FILE_SIZE_UNIT_BYTE : return $ doubleFileSize * 1024 ; case \ Document :: FILE_SIZE_UNIT_MB : return $ doubleFileSize / 1024 ; case \ Document :: FILE_SIZE_UNIT_GB : return $ doubleFileSize / 1024 / 1024 ; } } else if ( $ strSourceUnit == \ Document :: FILE_SIZE_UNIT_MB ) { switch ( $ strTargetUnit ) { case \ Document :: FILE_SIZE_UNIT_BYTE : return $ doubleFileSize * 1024 * 1024 ; case \ Document :: FILE_SIZE_UNIT_KB : return $ doubleFileSize * 1024 ; case \ Document :: FILE_SIZE_UNIT_GB : return $ doubleFileSize / 1024 ; } } else if ( $ strSourceUnit == \ Document :: FILE_SIZE_UNIT_GB ) { switch ( $ strTargetUnit ) { case \ Document :: FILE_SIZE_UNIT_BYTE : return $ doubleFileSize * 1024 * 1024 * 1024 ; case \ Document :: FILE_SIZE_UNIT_KB : return $ doubleFileSize * 1024 * 1024 ; case \ Document :: FILE_SIZE_UNIT_MB : return $ doubleFileSize * 1024 ; } } // no match return - 1 ; }
Utility function to convert file size from a source unit into a target unit.

@param	double	$doubleFileSize	The file size value.
@param	string	$strSourceUnit	The source unit of the file size.
@param	string	$strTargetUnit	The target unit of the file size.
@return	double	The converted file size value.
Utility function to convert file size from a source unit into a target unit .