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 each match in matches newstr=replace(newstr,match.value,saveimg(match.value)) next myreplace=newstr end function
function saveimg(url) temp=split(url,".") filename=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&"."&temp(ubound(temp)) '文件名重命名結束 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) if objAdostream.size<200 then response.write "沒找到內容![返回]" response.end end if objAdostream.SaveToFile(server.mappath(savepath&"\"&filename)) objAdostream.SetEOS set objAdostream=nothing imgpath01=savepath&"\"&filename '返回圖片路徑 imgpath01=replace(imgpath01,"\","/") response.write ("圖片上傳成功! [繼續上傳]") response.write (" http://www.dns.com.cn域名65元,空間聯系默飛可以享受八折優惠,信賴默飛沖天....") 'ad response.write (" ") '根據你的系統需要,更改返回方式. end function
Function mofeifoldfso(mpath) Set fso = Server.CreateObject("Scripting.FileSystemObject") if not fso.FolderExists(server.Mappath(mpath)) then fso.Createfolder(server.mappath(mpath)) set fso=nothing End Function %>
[Ctrl+A 全選 注:如需引入外部Js需刷新才能執行]