<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=99999savepath="upfiles" '圖片儲存路徑,可以根據自己的需要,進行修改,如沒有建立此檔案夾,系統將自動建立'QQ:33224360'HOME:http://mofei.xinxiu.com'EMAIL:mofei5@yahoo.com.cn'2005-10-15'著作權說明不影響資源,請保留著作權資訊imgpath=request("imgpath")if imgpath="" thenresponse.write "<form name=mofeiform method=post action=''><input type=text name=imgpath size=35> <input type=submit name=Submit001 value=上傳></form>在輸入框中輸入遠程圖片地址,如圖片不存在,程式自動放棄本次操作.製作:默飛QQ:33224360示範:http://mofei.xinxiu.com<font color=red>http://www.dns.com.cn</font><b>網域名稱65元,空間聯絡默飛可以享受八折優惠,<font color=red>信賴</font>默飛衝天....</b>"elsefilepath02=mofeifoldfso(savepath)savepath=savepath&"\"&year(now())&month(now())filepath02=mofeifoldfso(savepath)urname01=myreplace(imgpath)end if</P><P>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</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,falsexmlhttp.sendimg=xmlhttp.ResponseBodyset xmlhttp=nothingset objAdostream=server.createobject("ADODB.Stream")objAdostream.Open()objAdostream.type=1objAdostream.Write(img)if objAdostream.size<200 thenresponse.write "<font color=red>沒找到內容!</font>[返回]"response.endend ifobjAdostream.SaveToFile(server.mappath(savepath&"\"&filename))objAdostream.SetEOSset objAdostream=nothingimgpath01=savepath&"\"&filename '返回圖片路徑imgpath01=replace(imgpath01,"\","/")response.write ("圖片上傳成功! [繼續上傳]") response.write ("<font color=red>http://www.dns.com.cn</font><b>網域名稱65元,空間聯絡默飛可以享受八折優惠,<font color=red>信賴</font>默飛衝天....</b>") 'adresponse.write ("") '根據你的系統需要,更改返回方式.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=nothingEnd Function%></P><P></body></html>
[Ctrl+A 全選 注:如需引入外部Js需重新整理才能執行]