当前位置: 移动技术网 > IT编程>开发语言>Asp > ASP远程保存图片

ASP远程保存图片

2017年12月12日  | 移动技术网IT编程  | 我要评论
<% 
'先下载远程图片 
url=\"http://www.im286.com/image... '远程图片地址 
savepath=\"d:\photo\\" '保存路径 
'为文件重命名 
randomize 
rannum=int(999*rnd) 
filename=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&rannum 
'为文件重命名结束 
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(savepath&filename&\".jpg\") 
objadostream.seteos 
set objadostream=nothing 
'文件下载结束 
set upload = server.createobject(\"persits.upload\") '打开对象 
set file = upload.openfile(savepath&filename&\".jpg\") '打开已经保存的文件 

if file.imagetype <> \"jpg\" and file.imagetype <> \"gif\" and file.imagetype <> \"bmp\" and file.imagetype <> \"png\" then 
upload.deletefile savepath&filename&\".jpg\" '如果格式不正确就删除这张已下载的图片 
response.write \"错误的图片格式\" 
end if 
'注销实例 
set upload = nothing 
set file = nothing 
%>

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网