ASP download remote server file [Rar,jpg,gif,zip,png]

Source: Internet
Author: User
Tags rar

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);
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.