您的位置:首页 > 编程语言 > ASP

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

2007-09-13 11:42 956 查看
<%
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 " 文件上传成功,请提交!"
response.end
imgurl=savepath&filename&".jpg" '此句赋值之后可以写入数据库
%>

 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  input action 数据库 xml