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

首頁 > 網(wǎng)站 > 幫助中心 > 正文

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

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

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

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

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

'==================================
'=函 數(shù) 名:saveimgfile
'=功 能: 保存遠程圖片
'=參數(shù)說明:imgfileurl--遠程圖片地址
'=修改日期: 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)'獲取遠程圖片的格式
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'如果不是允許保存到本地的圖片格式,則只連接遠程圖片
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 '如果保存成功,即返回遠程地址,只作遠程連接,避免一些防盜連網(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">同時保存遠程圖片

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

ok,完工

希望大家能舉一返回,其它用到圖片的地方也是一樣的調(diào)用方法。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 桦川县| 大埔县| 隆子县| 漯河市| 仁布县| 旅游| 临沂市| 江门市| 衡南县| 巍山| 新宁县| 郴州市| 轮台县| 吉隆县| 当雄县| 林甸县| 依安县| 沈丘县| 东乌珠穆沁旗| 澳门| 黔西| 文水县| 靖州| 库车县| 开封市| 行唐县| 百色市| 定南县| 贺兰县| 宁德市| 阜新| 望城县| 洪湖市| 东安县| 浦江县| 两当县| 安多县| 卓尼县| 高淳县| 郴州市| 莱芜市|