原创  AspJpeg组件实现远程图片保存的实例完整代码 收藏

<%
Server.ScriptTimeOut=99999
savepath="upfiles/" '图片保存路径,可以根据自己的需要,进行修改,如没有创建此文件夹,系统将自动创建
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><br/>在输入框中输入远程图片地址,如图片不存在,程序自动放弃本次操作."
else

str = right(imgpath,3)
if str<>"jpg" and str<>"gif" then
 response.write "文件格式不正确 [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
response.end
end if

'为文件重命名
randomize
ranNum=int(999*rnd)
filename=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum
'为文件重命名结束

set mXmlHttp = Server.CreateObject("Msxml2.XMLHTTP")
mXmlHttp.open "GET",imgpath,false
mXmlHttp.send strPostData

Set jpeg1 = Server.CreateObject("Persits.Jpeg")
jpeg1.OpenBinary(mXmlHttp.responseBody)
jpeg1.Width = 130
jpeg1.Height = 100
jpeg1.Save(server.mappath(savepath&filename&".jpg"))
Set Jpeg1 = Nothing
end if
Response.write "&nbsp;文件上传成功,请提交!"
response.end
imgurl=savepath&filename&".jpg" '此句赋值之后可以写入数据库
%>

 

 

发表于 @ 2007年09月13日 11:42:00 | 评论( loading... ) | 编辑| 举报| 收藏

旧一篇:AspUpload组件的方法中文说明 | 新一篇:读GI源码、学JS编程——Javascript动态加载技术。

  • 发表评论
  • 评论内容:
  •  
Copyright © dianfeng21sj
Powered by CSDN Blog