日期:2010-02-08 浏览次数:21014 次
以下是引用片段: <% Dim url,aSize Url = "http://www.aiyiweb.com/download/xml.rar" aSize = getRemoteFileSize(Url) Response.Write Url & "<hr>" & aSize(0) & "<hr>" & aSize(1) ’--------------------------------------------------- ’功能: ASP获取远程文件大小 ’参数: Url 目标地址 ’返回: 返回数组 0:文件字节大小 1:格式化的文件大小 ’--------------------------------------------------- Function getRemoteFileSize(Url) Dim obj,a(1),r Set obj = CreateObject("MSXML2.XMLHTTP") obj.Open "GET",url, False obj.setRequestHeader "Range","bytes=-1" obj.send r = Split(obj.GetResponseHeader("Content-Range") & "/0","/") Set Obj = Nothing a(0) = CLng(r(1)) a(1) = a(0) / 1024 If a(1) > 1024 Then a(1) = Round(a(1) / 1024,2) & "MB" Else a(1) = Round(a(1),2) & "KB" End If getRemoteFileSize = a End Function %> |