怎样用asp实现,下载指定网址文件,并重命名后保存到本地服务器上?

来源:百度知道 编辑:UC知道 时间:2024/06/08 03:13:44
说明:1、比如指定网址为"http://www.xxx.com/1.txt"
2、通过一个按钮,把指定网址文件(1.txt)重命名后保存到服务器跟目录下。
3、要asp源码,并使用VBScript脚本。
指定文件为xml格式

download.asp
<%
'Code By oday

url =Trim(Request.QueryString("url")) '注意URL路径上的文件不能是被IIS解析的,如.txt就不行,要用的话自己改个后缀
fname=Trim(Request.QueryString("fname"))

if url <> "" then 'and fname<>"" then
Set xPost = CreateObject("Microsoft.XMLHTTP")
xPost.Open "GET",url,False
xPost.Send()
Set sGet = CreateObject("ADODB.Stream")
sGet.Mode = 3
sGet.Type = 1
sGet.Open()
sGet.Write(xPost.responseBody)
sGet.SaveToFile Server.MapPath(".")&"/"&fname,2
set sGet = nothing
set sPOST = nothing
response.Write("下载成功!<br>")
end if

%>
test.asp
<script>
location.href="download1.asp?url="+escape("http://58.211.102.206/hi/流行