asp下实现格式化文件大小以MB显示的函数

  <%

  '******************************

  '函数:FormatFileSize(l1)

  '参数:l1,字节数

  '作者:阿里西西

  '日期:2007/7/12

  '描述:格式化文件大小样式

  '示例:<%=FormatFileSize(l1)%>

  '******************************

  function FormatFileSize(l1)

  dim l2,l3

  l3=formatnumber(l1,0,true)

  if l1>1048576 then

  l2="("&formatnumber(l1/1048576,0,true)&" MB) "&l3

  else

  if l1>1024 then

  l2="("&formatnumber(l1/1024,0,true)&" KB) "&l3

  else

  l2=formatnumber(l1,0,true)

  end if

  end if

  llI=l2

  end function

  %>