国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

保存遠(yuǎn)程圖片函數(shù)修改正版

2020-07-27 13:32:25
字體:
供稿:網(wǎng)友
趁今天有空,修正了一下這個函數(shù),經(jīng)測試,在本地服務(wù)器通過,在空間商服務(wù)器也可正常使用,沒發(fā)現(xiàn)錯誤。我的卡巴斯基不報毒了。^_^

只要修改一下,這個函數(shù)是放在哪個網(wǎng)站都適用的。在此只與添加圖片為例說明一下調(diào)用方法,其它位置方法類似。

在我本機(jī)測試成功,由于現(xiàn)在連不上空間的FTP,所以無辦在空間上測試,發(fā)現(xiàn)問題請到群中提出。

一、把下面函數(shù)放到Ft_admin_conn.asp的最后

'==================================
'=函 數(shù) 名:saveimgfile
'=功 能: 保存遠(yuǎn)程圖片
'=參數(shù)說明:imgfileurl--遠(yuǎn)程圖片地址
'=修改日期: 2006-4-19 13:20
'=程序作者:冷風(fēng)
'=網(wǎng) 站:http://www.4fnet.com.cn
'==================================
function saveimgfile(imgfileurl)
dim img_type,savepath,imgfiletype,flag,imgbody
savepath="../FUploadFile/"&year(now())&"-"&month(now())
flag=false
imgfiletype=right(imgfileurl,4)'獲取遠(yuǎn)程圖片的格式
img_type=".gif|.bmp|.jpg|.png"'設(shè)置允許保存在本地的圖片格式
typeArr=split(img_type,"|")
for i=0 to ubound(typeArr)-1
if imgfiletype=typeArr(i) then
flag=true
exit for
end if
next
if flag=false then'如果不是允許保存到本地的圖片格式,則只連接遠(yuǎn)程圖片
saveimgfile=imgfileurl
else
set xml_http=server.createobject("microsoft.xmlhttp")
xml_http.open "get",imgfileurl,false
xml_http.send
imgbody=xml_http.responsebody
set xml_http=nothing
serverpath=server.mappath(savepath)
set filefolder=server.createobject("scripting.filesystemobject")
if filefolder.folderexists(serverpath)=false then
filefolder.createfolder(serverpath)
end if
randomize
savepath=savepath&"/"&year(now())&month(now())&day(now())&hour(now())&minute(now())&int(10*rnd)&imgfiletype
set adodbs=server.createobject("adodb.stream")
adodbs.open
adodbs.type=1
adodbs.write imgbody
adodbs.savetofile(server.mappath(savepath))'保存到本地
adodbs.seteos
set adodbs=nothing
if filefolder.fileexists(server.mappath(savepath))=false then '如果保存成功,即返回遠(yuǎn)程地址,只作遠(yuǎn)程連接,避免一些防盜連網(wǎng)站不能保存
saveimgfile=imgfileurl
else
savepath=replace(savepath,"../","")
saveimgfile=savepath
end if
set filefolder=nothing
end if
end function

二、打開admin/admin_pic.asp文件
1、找到:添加圖片過程中的 pic_pic=checksql("縮略圖片地址",request.form("pic"),1,100) (大概在第368行)在下面插入代碼:

if left(pic_url,7)="http://" and request.form("save")="true" then
pic_url=saveimgfile(pic_url)
pic_pic=pic_url
end if
  再找到:<input type="submit" name="Submit" value="確定新增"> (大概在第481行)插入以下代碼:

   <input type="checkbox" name="save" value="true">同時保存遠(yuǎn)程圖片

2、在編輯圖片過程(editpic)中的相同地方添加相應(yīng)的代碼即可。

ok,完工

希望大家能舉一返回,其它用到圖片的地方也是一樣的調(diào)用方法。

歡迎光臨本站:http://www.4fnet.com.cn
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 四子王旗| 平和县| 高清| 温州市| 丹巴县| 舒城县| 瑞金市| 大同市| 左贡县| 红桥区| 南川市| 天门市| 波密县| 渝北区| 资源县| 吴川市| 延边| 密山市| 玉龙| 孟州市| 法库县| 吉隆县| 化隆| 湖州市| 从化市| 柏乡县| 江永县| 梁河县| 镇沅| 澄迈县| 九龙县| 长乐市| 新巴尔虎右旗| 麦盖提县| 民和| 东乌珠穆沁旗| 房山区| 许昌市| 奉新县| 平顶山市| 区。|