ASP remote image saving

Source: Internet
Author: User

<%
'Download the remote image first
Url = \ "http://www.im286.com/image... 'Remote Image address
Savepath = \ "D: \ photo \" 'Save path
'Rename the file
Randomize
Rannum = int (999 * RND)
Filename = year (now) & month (now) & Day (now) & hour (now) & minute (now) & Second (now) & rannum
'The End Of The file rename
Set XMLHTTP = server. Createobject (\ "Microsoft. XMLHTTP \")
XMLHTTP. Open \ "Get \", URL, false
XMLHTTP. Send
IMG = XMLHTTP. responsebody
Set XMLHTTP = nothing
Set objadostream = server. Createobject (\ "ADODB. Stream \")
Objadostream. open ()
Objadostream. type = 1
Objadostream. Write (IMG)
Objadostream. savetofile (savepath & filename & \ ". jpg \")
Objadostream. seteos
Set objadostream = nothing
'File download ended
Set upload = server. Createobject (\ "persits. Upload \") 'Open the object
Set file = upload. openfile (savepath & filename & \ ". jpg \") 'Open the saved file

If file. imagetype <> \ "JPG \" and file. imagetype <> \ "GIF \" and file. imagetype <> \ "BMP \" and file. imagetype <> \ "PNG \" then
Upload. deletefile savepath & filename & \ ". jpg \" 'Delete the downloaded image if the format is incorrect.
Response. Write \ "incorrect image format \"
End if
'Deregistering an instance
Set upload = nothing
Set file = nothing
%>

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.