Save the picture involved in the article to the local server

xiaoxiao2021-03-06  48

<% 'Function function: Save the picture involved in the article to the local server. (Note: Please create tempfile directory under the directory used to store temporary Pictures) 'Author: small gray' QQ: 103895 'home page: http: //asp2004.net'2004.9.13' Do not reprint or delete these above information. Thank you!

Const SavePath = "TempFile /"

function myreplace (str) newstr = strset objregEx = new RegExpobjregEx.IgnoreCase = trueobjregEx.Global = trueobjregEx.Pattern = "http: // / (jpg | gif | png | bmp) ( .?)." set matches = objregEx. Execute (STR) for Each Match in matchesnewstr = replace (newstr, match.value, saveimg (match.value) NextMyreplace = newstrend function

Function SaveImg (URL) Temp = Split (URL, ".") Randomizrannum = INT (90000 * RND) 10000FileName = Year (NOW) & Month (now) & half & Hour (now) & second (now) & ranNum & "." & temp (ubound (temp)) set xmlhttp = server.createobject ( "Microsoft.XMLHTTP") xmlhttp.open "get", url, falsexmlhttp.sendif xmlhttp.status <> 200 then saveimg = "" else img = xmlhttp.ResponseBody set objAdostream = server.createobject ( "ADODB.Stream") objAdostream.Open () objAdostream.type = 1 objAdostream.Write (img) objAdostream.SaveToFile (server.mappath ( "./"& savepath & filename)) objAdostream.SetEOS Set objadostream = Nothing SaveImg = SavePath & FileNameEnd ifset Xmlhttp = Nothingend Function%>

转载请注明原文地址:https://www.9cbs.com/read-117623.html

New Post(0)