這是一段用ASP程序獲取遠(yuǎn)程文件大小的函數(shù),看起來很簡單,icech推薦給大家學(xué)習(xí)一下:
<%
'-----------------------------------------------------------
'功能:獲取遠(yuǎn)程文件大小
'參數(shù):url 遠(yuǎn)程文件地址
'返回:遠(yuǎn)程文件大小(單位:字節(jié))
'-----------------------------------------------------------
Function getRemoteFileSize(url)
Dim xmlHTTP
Set xmlHTTP = Server.CreateObject("MSXML2.XMLHTTP")
xmlHTTP.open "get", url, false
'下一句非常關(guān)鍵,否則要預(yù)加載全部的文件信息后才返回header頭信息
xmlHTTP.setRequestHeader "range", "bytes=-1"
xmlHTTP.send()
getRemoteFileSize = Split(xmlHTTP.GetResponseHeader("Content-Range"),"/")(1)
Set xmlHTTP = Nothing
End Function
Response.Write(getRemoteFileSize("http://js.#cn.yahoo.com/i.gif"))
%>