最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp下载远程服务器文件[rar,jpg,gif,zip,png]
时间:2022-07-02 23:08:37 编辑:袖梨 来源:一聚教程网
asp下载远程服务器文件[rar,jpg,gif,zip,png]
< %
function downfilea(d_target, s_target)
On Error Resume Next
dim myhttp, objstream
set myhttp = server.createobject( "MSXML2.XMLHTTP ")
myhttp.open "GET ", d_target, false
myhttp.send()
set objstream = Server.CreateObject( "adodb.stream ")
objstream.Type = 1
objstream.Mode = 3
objstream.Open
objstream.Write myhttp.responseBody
objstream.SaveToFile s_target, 2
if err.number <> 0 then err.Clear
end function
downfilea "http://www.111com.net/xxx.rar ", Server.MapPath( "down/xxx.rar ")
Response.write "ok "
%>
还有asp.net版本的源码(未测试)
using System;
using System.Net;
using System.IO;
class DownloadFile;
{
static void Main(string[] args)
{
//你的远程文件
string siteURL="http://www.abc.com/xxx.rar";
//下载到本地的路径及文件名
string fileName="c:xxx.rar";
//实例化一个WebClient
WebClient client=new WebClient();
//调用WebClient的DownloadFile方法
client.DownloadFile(siteURL,fileName);
}
}