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" '此句賦值之後可以寫入數據庫
%>

 

 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章