展开全部
示例如下
<%
function saveimg(url)
dim temp,ranNum,filename,xmlhttp,imgcon,objAdostream,savepath,rdate,rfolder
savepath=server.mappath("/pic")
'response.write server.mappath("/pic")
'savepath=replace(savepath,"\","/")
'savepath=savepath&"/"
'savepath=replace(savepath,"//","/")
temp=split(url,".")
'以下是用时间与随机数重命名文件名
rdate=now
randomize
ranNum=int(90000*rnd)+10000
filename=year(rdate)&month(rdate)&day(rdate)&hour(rdate)&minute(rdate)&second(rdate)&ranNum&"."&temp(ubound(temp))
'文件名重命名结束
'rfolder=year(rdate)&"_"&month(rdate)
'if len(month(now))<2 then
'rfolder=year(now)&"0"&month(now)
'else
'rfolder=year(now)&month(now)
'end if
'savepath=savepath&rfolder
'call FSOfolder(Server.MapPath(savepath))
set xmlhttp=server.createobject("Mi"&"cros"&"oft.XM"&"LHTTP")
xmlhttp.open "get",url,false
xmlhttp.send
imgcon=xmlhttp.ResponseBody
set xmlhttp=nothing
set objAdostream=server.createobject("AD"&"ODB"&".Str"&"eam")
objAdostream.Open()
objAdostream.type=1
objAdostream.Write(imgcon)
'response.write savepath
objAdostream.SaveToFile(savepath&"/"&filename)
objAdostream.SetEOS
set objAdostream=nothing
saveimg=savepath&"/"&filename
response.write saveimg
end function
call saveimg("http://www.sinaimg.cn/home/07index/sinahome_ws_009.gif")
%>
<%
function saveimg(url)
dim temp,ranNum,filename,xmlhttp,imgcon,objAdostream,savepath,rdate,rfolder
savepath=server.mappath("/pic")
'response.write server.mappath("/pic")
'savepath=replace(savepath,"\","/")
'savepath=savepath&"/"
'savepath=replace(savepath,"//","/")
temp=split(url,".")
'以下是用时间与随机数重命名文件名
rdate=now
randomize
ranNum=int(90000*rnd)+10000
filename=year(rdate)&month(rdate)&day(rdate)&hour(rdate)&minute(rdate)&second(rdate)&ranNum&"."&temp(ubound(temp))
'文件名重命名结束
'rfolder=year(rdate)&"_"&month(rdate)
'if len(month(now))<2 then
'rfolder=year(now)&"0"&month(now)
'else
'rfolder=year(now)&month(now)
'end if
'savepath=savepath&rfolder
'call FSOfolder(Server.MapPath(savepath))
set xmlhttp=server.createobject("Mi"&"cros"&"oft.XM"&"LHTTP")
xmlhttp.open "get",url,false
xmlhttp.send
imgcon=xmlhttp.ResponseBody
set xmlhttp=nothing
set objAdostream=server.createobject("AD"&"ODB"&".Str"&"eam")
objAdostream.Open()
objAdostream.type=1
objAdostream.Write(imgcon)
'response.write savepath
objAdostream.SaveToFile(savepath&"/"&filename)
objAdostream.SetEOS
set objAdostream=nothing
saveimg=savepath&"/"&filename
response.write saveimg
end function
call saveimg("http://www.sinaimg.cn/home/07index/sinahome_ws_009.gif")
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询