检测远程文件是否存在

时间: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
投稿

猜你喜欢

  • pyinstaller参数介绍以及总结详解

    2023-12-02 11:11:59
  • Python3自动安装第三方库,跟pip说再见

    2022-03-12 04:34:15
  • Access数据库用另一种方式管理密码

    2008-10-13 12:25:00
  • CSS解决未知高度的垂直水平居中自适应问题

    2009-03-17 17:06:00
  • Yii2框架整合Xunsearch搜索引擎的方法

    2024-06-05 09:37:48
  • 本地windows安装两个mysql服务器,配置主从同步

    2024-01-15 13:57:30
  • 浅谈pandas关于查看库或依赖库版本的API原理

    2023-10-14 04:54:13
  • python scrapy框架中Request对象和Response对象的介绍

    2021-04-02 07:29:59
  • Python 私有函数的实例详解

    2023-03-07 08:30:40
  • JavaScript:ES2019 的新特性(译)

    2024-04-10 16:16:57
  • 浅谈Pytorch中autograd的若干(踩坑)总结

    2022-11-01 01:11:06
  • python机器学习之贝叶斯分类

    2023-10-16 00:31:28
  • MySQL数据库搜索中的大小写敏感性

    2008-11-24 12:44:00
  • 一文掌握Go语言并发编程必备的Mutex互斥锁

    2024-05-13 10:43:30
  • Mysql视图和触发器使用过程

    2024-01-15 22:15:46
  • 判断浏览器是否接受 Cookie

    2009-07-28 17:52:00
  • Python 虚拟环境venv详解

    2021-04-12 03:44:14
  • Microsoft Enterprise Library 5.0 如何集成MyS

    2011-03-16 15:19:00
  • 设计规范有谱么?

    2008-06-06 12:28:00
  • C# 制作PictureBox圆形头像框并从数据库中读取头像

    2024-01-21 05:17:07
  • asp之家 网络编程 m.aspxhome.com