Server <%
' function function: To automatically save the pictures involved in the content of the article to the local server. (Note: Please create a tempfile directory under the directory to save the temporary picture)
' Author: Little Grey
' qq:103895
' Home: http://asp2004.net
' 2004.9.13
' Reprint or use please do not delete the above information. Thank you!
Const savepath= "tempfile/"
function Myreplace (str)
Newstr=str
Set Objregex = new REGEXP
Objregex.ignorecase = True
Objregex.global = True
Objregex.pattern = "http://(. +?) \. (jpg|gif|png|bmp) "
Set matches = Objregex.execute (str)
For the match in matches
Newstr=replace (Newstr,match.value,saveimg (Match.value))
Next
Myreplace=newstr
End Function
function saveimg (URL)
Temp=split (URL, ".")
Randomize
Rannum=int (90000*RND) +10000
Filename=year (now) &month (now), &day (now), &hour (now) &minute (now), &second (now) &ranNum& "." &temp (UBound (temp))
Set Xmlhttp=server.createobject ("Microsoft.XMLHTTP")
Xmlhttp.open "Get", Url,false
Xmlhttp.send
If 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&filename
End If
Set xmlhttp=nothing
End Function
%>