ASP download remote server file [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.111cn.net/xxx.rar", Server.MapPath ("Down/xxx.rar")
Response.Write "OK"
%>
There are asp.net version of the source code (not tested)
Using System;
Using System.Net;
Using System.IO;
Class DownloadFile;
{
static void Main (string[] args)
{
Your remote file.
String siteurl= "Http://www.abc.com/xxx.rar";
Download to local path and filename
String Filename= "C:\xxx.rar";
Instantiate a WebClient
WebClient client=new WebClient ();
Call the WebClient DownloadFile method
Client. DownloadFile (Siteurl,filename);
}
}