检测远程文件是否存在

时间:2009-06-22 13:00:00 

代码'###########
'检测远程文件是否存在
'###########
function CheckURL(byval A_strUrl)
         set XMLHTTP = Server.CreateObject("Microsoft.XMLHTTP")
         XMLHTTP.open "HEAD",A_strUrl,false
         XMLHTTP.send()
         CheckURL=(XMLHTTP.status=200)
         set XMLHTTP = nothing
end function

if CheckURL(DownLoadUrl) then
do  
else
do other...
end if

XMLHTTP检测远程文件存在与否
<%
response.write "检查是否开机<br>"
on error resume next
set xml=Server.createobject("Microsoft.XMLHTTP")
xml.open "get","http://www.hao114.com/ss.mdb",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 "地址正确<br>"
     end if
end if
if response.buffer then
response.flush
end if
%>

<html>
<head>
</head>
<script language="vbscript">
function bytes2BSTR(vIn)
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr (CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End function

function CheckUrl(url)
set oSend=createobject("Microsoft.XMLHTTP")
SourceCode = oSend.open ("GET",url,false)
oSend.send()
if instr(bytes2BSTR(oSend.responseBody),"Not Found")<>0 then
msgbox "此文件不存在"
else
msgbox "此文件存在"
end if
End function
</script>

<input name="myurl" id="myurl" type="textfield" value="">
<input type="button" onclick="CheckUrl(myurl.value)" value="检 测">
</html>


Function testURL(url)

Dim httpxml
Set httpxml = CreateObject("msxml2.XMLHTTP")
httpxml.open "HEAD",url,False
httpxml.send
If httpxml.status = 200 Then
testURL = 1
Else
testURL = 0
End If
Set httpxml = Nothing

End Function
if testurl("http://www.hao114.com/index.htm")=0 then
response.write"页面不存在"
else
response.write"页面存在"
end if

标签:远程,文件,xmlhttp
0
投稿

猜你喜欢

  • 用ASP对网页进行限制性的访问

    2008-07-03 13:02:00
  • asp下以Json获取中国天气网天气的代码

    2011-03-06 11:01:00
  • 如何实现全文检索?

    2010-05-24 18:24:00
  • 什么是Semantics?

    2008-04-16 13:45:00
  • 成为一个顶级设计师的第三准则

    2009-09-15 21:00:00
  • W3C 接连推出 7 个 HTML 草案

    2010-03-10 10:37:00
  • 确定能够释放空间的SQL Server数据库文件的脚本

    2010-07-31 12:36:00
  • IE10增强对HTML5和CSS3的支持

    2011-09-16 20:16:28
  • 分类与类型的问题

    2008-09-12 13:10:00
  • 段正淳的css笔记(5)未知图片垂直居中的方法

    2007-11-01 22:06:00
  • ImageMagicK convert crop参数说明

    2008-10-21 12:46:00
  • 利用ASP实现事务处理的方法

    2010-05-11 16:53:00
  • SQL Server数据库导入MySQL数据库体验

    2009-01-20 16:07:00
  • 使用xmlhttp为网站增加股市行情查询功能

    2007-10-10 21:09:00
  • 建立适当的索引是实现查询优化的首要前提

    2009-01-19 13:11:00
  • 为什么视觉设计师需要懂HTML

    2009-06-25 14:16:00
  • Javascript 每日测试 - 第五期 callee及function

    2008-07-10 13:22:00
  • 可爱动态背景输入框

    2009-05-07 13:50:00
  • Mysql5写中文乱码问题解决

    2007-09-17 12:38:00
  • SQL Server 2008中的MERGE(不仅仅是合并)

    2010-10-15 14:16:00
  • asp之家 网络编程 m.aspxhome.com