ASP Save Remote Pictures

Source: Internet
Author: User

Remember a lot of editors, automatic collection system is a function of automatically save remote pictures, probably the principle is to use the XMLHTTP object to get pictures, and then write to save with the stream object, referring to the online code, wrote a, and circulated code no difference! The code is as follows, one function:

<%
Function saveremotefile (ssavepath,sremotefileurl) on
Error Resume Next
saveremotefile = False
Dim Oxml:set oxml = Server.CreateObject ("Microsoft.XMLHTTP") with
oXML
. Open "Get", Sremotefileurl,false, "", ""
. Send
If. status<>200 Then Exit Function
remotedate =. Responsebody End and
Set oxml = Nothing
Dim ostream:set ostream = Server.CreateObject ("Adodb.strea M ") with
ostream
. Type = 1
. Open
. Write remotedate
. SaveToFile ssavepath,2
If err.number=0 Then saveremotefile = True
. Close () End with
Set ostream = Nothing End
Function

' Invoke method as follows

Saveaddr=server.mappath ("Demo.gif")
sourceurl= "Http://www.google.cn/intl/zh-CN/images/logo_cn.gif"
Call Saveremotefile (saveaddr,sourceurl)
%>
Tag

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.