关于打开指定页面自动下载代码

来源:百度知道 编辑:UC知道 时间:2024/06/28 05:31:04
判断远程文件是否存在.存在下载,不存在下载另外一个.
<%
response.write "检查是否开机<br>"
on error resume next
set xml=Server.createobject("Microsoft.XMLHTTP")
xml.open "get","http://www.292sf.cn/down/921sf.exe",false
xml.send
ints=xml.status
strs=xml.statustext
if isnumeric(ints) then
if ints=12007 or strs="Unknown" then
response.write "地址出错<br>"
end if
if ints=404 then
response.write "找不到文件<br>"
else
response.Write("<a href='http://www.292sf.cn/down/921sf.exe'><123456></a>")

response.write "地址正确<br>"
end if
end if
if response.buffer then
response.flu

没必要用GET把文件下载下来吧?你只是想检查文件是否存在?用HEAD就可以了,HEAD只是获取文件信息(包括文件长度,创建和修改日期等),不下载文件正文。

<%
Response.Write( "检查是否开机<br>" )
'on error resume next
targetUrl = "http://www.292sf.cn/down/921sf.exe"
Set xmlHttp = Server.Createobject( "Microsoft.XMLHTTP" )
xmlHttp.open "HEAD", targetUrl, false
xmlHttp.send()
If ( xmlHttp.status = 200 OR xmlHttp.status = 206 ) Then
Response.Write( targetUrl )
Else
Response.Write( "文件不存在" )
End If
Set xmlHttp = Nothing

%>