XMLHTTP下载远程数据输出到浏览器

利用xmlhttp对象获取远程的数据,然后用二进制输出到客户浏览器,让客户下载数据,此例从某一远程服务器获取一个压缩包,并且输出到浏览器提供客户下载.

程序代码:

 1   
 2Response.Buffer = True   
 3Dim objXMLHTTP, xml   
 4Set xml = Server.CreateObject("Microsoft.XMLHTTP") '创建对象   
 5  
 6xml.Open "GET"," http://www.4guysfromrolla.com/webtech/code/mitchell-pres.zip",False ' '设置对象,具体xmlhttp详细使用方法请见:http://www.cnsxml.com/blogview.asp?logID=273 《XMLHTTP 对象及其方法》一文 
 7
 8xml.Send '发送请求   
 9  
10Response.AddHeader "Content-Disposition", "attachment;filename=mitchell-pres.zip" '添加头给这个文件   
11  
12Response.ContentType = "application/zip" '设置输出类型   
13  
14Response.BinaryWrite xml.responseBody ’输出二进制到浏览器 
15
16Set xml = Nothing   
Published At
Categories with Web编程
Tagged with
comments powered by Disqus