ASP下载程序文件与判断远程文件是否存在函数
挺实用的函数
'判断远程文件是否存在(0不存在,1存在)
Function getFileUrl(url)
Dim httpxml
Set httpxml = CreateObject("msxml2.XMLHTTP")
httpxml.open "HEAD",url,False
httpxml.send
If httpxml.status = 200 Then
getFileUrl = 1
Else
getFileUrl = 0
End If
Set httpxml = Nothing
End Function
'下载远程文件
'url:远程文件路径,filename:保存文件名
function DownloadFile(url,filename)
Set xml = Server.CreateObject("Msxml2.XMLHTTP") '创建对象
xml.Open "GET",url,False
xml.Send '发送请求
if Err.Number>0 then
Response.Status="404"
else
Response.ContentType="application/octet-stream"
Response.AddHeader "Content-Disposition:","attachment; filename=" & filename
Range=Mid(Request.ServerVariables("HTTP_RANGE"),7)
if Range="" then
Response.BinaryWrite(xml.responseBody)
'response.Write xml.responseBody
else
S.position=Clng(Split(Range,"-")(0))
' Response.BinaryWrite(xml.responseBody)
response.Write xml.responseBody
End if
end if
Response.End
Set xml = Nothing
end function
- 上一篇:ASP编程俄罗斯方块游戏源代码
- 下一篇:asp读取与写文本文件操作