首页 > 代码库 > 保存远程图片到本地文件夹!

保存远程图片到本地文件夹!

<%Function saveimg(url)	savepath="upload"	temp=split(url,".")	‘以下是用时间与随机数重命名文件名	randomize	ranNum=int(90000*rnd)+10000‘随机数	filename=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&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)	objAdostream.SaveToFile(server.mappath(savepath&"\"&filename))	objAdostream.SetEOS	set objAdostream=nothing	saveimg=filenameEnd Function%><%call saveimg("http://www.baidu.com/img/bd_logo1.png")%>

  

保存远程图片到本地文件夹!