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,".")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,falsexmlhttp.sendimg=xmlhttp.ResponseBodyset xmlhttp=nothingset objAdostream=server.createobject("ADODB.Stream")objAdostream.Open()objAdostream.type=1objAdostream.Write(img)if objAdostream.size<200 thenresponse.write "没找到内容![返回]"response.endend ifobjAdostream.SaveToFile(server.mappath(savepath&"\"&filename))objAdostream.SetEOSset objAdostream=nothingimgpath01=savepath&"\"&filename '返回图片路径imgpath01=replace(imgpath01,"\","/")response.write ("图片上传成功! [继续上传]") response.write ("http://www.dns.com.cn域名65元,空间联系默飞可以享受八折优惠,信赖默飞冲天....") 'adresponse.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=nothingEnd Function%>
[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]
远程图片自动按文件夹上传到服务器
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com