<% On Error Resume Next Response.Expires = 0 Dim Uploader, File Dim objConn, objRS, strQuery, IobjCheck, ICheckQuery, NstrQuery, UobjRS, UstrQuery, UstrQuery2, UstrQuery1, DobjRS, DstrQuery, DstrQuery2, DstrQuery1 Dim strConnection Dim tPID, tPhotoID, tPhoto Dim fso, tOName, tNName if Session("Admin") = "" then Response.Write "
You have been logout.
" else Set objConn = Server.CreateObject("ADODB.Connection") strConnection = "DSN=pdsb;Database=BlogDB.mdb;" objConn.Open strConnection Set Uploader = New FileUploader Uploader.Upload() Set fso = CreateObject("Scripting.FileSystemObject") tPID = Uploader.Form("PID") tDel = Uploader.Form("Del" & intLoop) if tDel <> "" then RstrQuery = "SELECT * FROM Product WHERE ID = " & tPID set RobjRS = objConn.Execute(RstrQuery) if fso.FileExists(Server.MapPath("/bDocument") & "/" & RobjRS("Document")) then fso.DeleteFile(Server.MapPath("/bDocument") & "/" & RobjRS("Document")) end if strQuery = "UPDATE Product SET Document = '' WHERE ID = " & tPID objConn.Execute(strQuery) Response.Redirect("productDocumentEdit.asp?pid=" & tPID) End If For Each File In Uploader.Files.Items tFileName = File.FileName DCheckQuery = "SELECT ID FROM Product WHERE Document = '" & tFileName & "'" set DobjCheck = objConn.execute(DCheckQuery) if not DobjCheck.EOF then count = 0 tDID = DobjCheck("ID") Do While not DobjCheck.EOF count = count + 1 DCheckQuery = "SELECT ID FROM Product WHERE Document = '" & count & tFileName & "'" set DobjCheck = objConn.execute(DCheckQuery) Loop tOName = Server.MapPath("/bDocument") & "\" & tFileName tNName = Server.MapPath("/bDocument") & "\" & count & tFileName Set fso = CreateObject("Scripting.FileSystemObject") fso.MoveFile tOName, tNName NstrQuery = "UPDATE Product SET Document = '" & count & tFileName & "' WHERE ID = " & tDID objConn.execute(NstrQuery) end if Path = Server.MapPath("/bDocument") File.SaveToDisk (Path) PstrQuery = "UPDATE Product SET Document = '" & tFileName & "' WHERE ID = " & tPID objConn.Execute(PstrQuery) DobjCheck.close Set DobjCheck = Nothing Next Response.Redirect("productDocumentEdit.asp?pid=" & tPID) objConn.close Set objConn = Nothing end if %>