<html> <head> <meta http-equiv="content-Type" content="text/html; charset=gb2312"> <title>远程图片自动按文件夹上传到服务器-默飞出品</title> <style type=text/css> a { text-decoration: none; color: blue } a:hover { text-decoration: underline } body { scrollbar-base-color: #F8F8F8; scrollbar-arrow-color: #698CC3; font-size: 12pt; background-color: #ffffff } </style> <body topmargin="0" bgcolor="#F9F9F9"> <% '远程图片自动按文件夹上传到服务器 '制作:默飞 Server.ScriptTimeOut=99999 savepath="upfiles" '图片保存路径,可以根据自己的需要,进行修改,如没有创建此文件夹,系统将自动创建 'QQ:33224360 'HOME:http://mofei.xinxiu.com 'EMAIL:mofei5@yahoo.com.cn '2005-10-15 '版权说明不影响资源,请保留版权信息 imgpath=request("imgpath") if imgpath="" then response.write "<form name=mofeiform method=post action=''><input type=text name=imgpath size=35> <input type=submit name=Submit001 value=上传></form> 在输入框中输入远程图片地址,如图片不存在,程序自动放弃本次操作. 制作:默飞 QQ:33224360 演示:<a href=http://mofei.xinxiu.com target=_blank>http://mofei.xinxiu.com</a> <a href=http://www.dns.com.cn target=_blank><font color=red>http://www.dns.com.cn</font></a><b>域名65元,空间联系默飞可以享受八折优惠,<font color=red>信赖</font><a href=http://mofei.xinxiu.com target=_blank>默飞冲天</a>....</b>" else filepath02=mofeifoldfso(savepath) savepath=savepath&"\"&year(now())&month(now()) filepath02=mofeifoldfso(savepath) urname01=myreplace(imgpath) end if</P> <P>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</P> <P>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 "<font color=red>没找到内容!</font>[<a href=# onclick=history.go(-1)>返回</a>]" response.end end if objAdostream.SaveToFile(server.mappath(savepath&"\"&filename)) objAdostream.SetEOS set objAdostream=nothing imgpath01=savepath&"\"&filename '返回图片路径 imgpath01=replace(imgpath01,"\","/") response.write ("图片上传成功! [<a href=# onclick=history.go(-1)>继续上传</a>]") response.write (" <a href=http://www.dns.com.cn target=_blank><font color=red>http://www.dns.com.cn</font></a><b>域名65元,空间联系默飞可以享受八折优惠,<font color=red>信赖</font><a href=http://mofei.xinxiu.com target=_blank>默飞冲天</a>....</b>") 'ad response.write (" <img src="&imgpath01&" _ewebeditor_ta_src="%26imgpath01%26" border=0 alt=默飞制作>") '根据你的系统需要,更改返回方式. end function</P> <P>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 %></P> <P></body> </html> [Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]