
<%
' 刪除指定的文件
Sub DoDelFile(sPathFile)
On Error Resume Next
Dim oFSO
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
oFSO.DeleteFile(Server.MapPath(sPathFile))
Set oFSO = Nothing
End Sub
'刪除某條新聞信息
if objaction="del" then
' 取參數:新聞ID
Dim sNewsID
sNewsID = Trim(Request("id"))
' 新聞ID有效性驗證,防止有些人惡意的破壞此演示程序
If IsNumeric(sNewsID) = False Then
call errbox("請通過(guò)頁(yè)面上的鏈接進(jìn)行操作,不要試圖破壞此演示系統","","","","")
End If
set dirs=server.CreateObject("adodb.recordset")
dirs.open "select * from news where id="&sNewsID,conn,1,1
if dirs.eof and dirs.bof then
call errbox("無(wú)效的新聞ID,請點(diǎn)頁(yè)面上的鏈接進(jìn)行操作","","","","")
else
sSavePathFileName = dirs("saveimg")
end if
dirs.close
set dirs=nothing
' 從新聞數據表中取出相關(guān)的上傳文件
' 上傳后保存到本地服務(wù)器的路徑文件名,多個(gè)以"|"分隔
' 刪除文件,要取帶路徑的文件名才可以,并且只要這個(gè)就可以了,原來(lái)存的原文件名或不帶路徑的保存文件名可用于其它地方使用
Dim sSavePathFileName
' 把帶"|"的字符串轉為數組
Dim aSavePathFileName
aSavePathFileName = Split(sSavePathFileName, "|")
' 刪除新聞相關(guān)的文件,從文件夾中
Dim i
For i = 0 To UBound(aSavePathFileName)
' 按路徑文件名刪除文件
Call DoDelFile(aSavePathFileName(i))
'response.write Server.MapPath(aSavePathFileName(i)) & "<br>"
Next
dddSQL="Delete * from [news] where id in ("&request("id")&")"
conn.Execute (dddSQL)
response.redirect "qwbm.asp"
response.end
end if
%>
呢 稱(chēng): | |
表 情: | |
內 容: |
評論內容:不能超過(guò) 1000 字,需審核,請自覺(jué)遵守互聯(lián)網(wǎng)相關(guān)政策法規。 |
驗證碼: | |
您發(fā)布的評論即表示同意遵守以下條款:
一、不得利用本站危害國家安全、泄露國家秘密,不得侵犯國家、社會(huì )、集體和公民的合法權益;
二、不得發(fā)布國家法律、法規明令禁止的內容;互相尊重,對自己在本站的言論和行為負責;
三、本站對您所發(fā)布內容擁有處置權。