Set Conn=Server.CreateObject("ADODB.Connection")
Conn.Open("DSN=xxx;UID=xx;PWD=;") Set FSO = CreateObject("Scripting.FileSystemObject") set UploadForm = Server.CreateObject("SiteGalaxyUpload.Form") no = UploadForm("no") file1 = UpLoadForm("file1") SQL = "SELECT filename1 FROM databank WHERE no = " & no Set rs = Server.CreateObject("ADODB.Recordset") rs.Open SQL,conn,1 filename1_b=trim(rs("filename1")) if Len(file1) > 0 then strFile = "c:/inetpub/wwwroot/" & filename1_b If (FSO.FileExists(strFile)) Then FSO.DeleteFile(strFile) End If attach_file = UploadForm("file1").FilePath FileName1 = Mid(attach_file, InstrRev(attach_file, "\") + 1) strName = Mid(FileName1, 1, Instr(FileName1, ".") - 1) strExt = Mid(FileName1, Instr(FileName1, ".") + 1) bExist = True strFileName = channel02 & strName & "." & strExt countFileName = 0 Do While bExist If (FSO.FileExists(strFileName)) Then countFileName = countFileName + 1 FileName1 = strName & "_" & countFileName & "." & strExt strFileName = "c:\inetpub/wwwroot/" & FileName1 Else bExist = False End If Loop 'response.write strFileName UploadForm("file1").SaveAs strFileName end if '-------------------------------------------- ' 파일에 관련 디비 업데이트 '-------------------------------------------- if Len(file1) > 0 then SQL = "Update databank set filename1 = '" & filename1 & "'" SQL = SQL & " where no = " &no Conn.Execute(SQL) end if Response.Redirect "board.asp" 먼저 소스를 보여 드렸습니다...... 소스를 따라가 보면 쉽게 알 수 있는 내용으로 되어 있습니다. 글쓰기 부분과 다른부분이 거의 없이 처리가 되기 때문에 다른 것은 넘어가기로 하겠습니다.... 레코드 번호(no)와 업데이트 시킬 파일을 가져 왔습니다. (file1, file2) if Len(file1) > 0 then 명령은 ,,, 만약 file1 이나 file2에 아무값도 들어오지 않았다면,,,, 수정을 해주면 안됩니다.... 수정을 하고 싶은 파일의 이름이 없을땐, 처리하지 않습니다. 만약 파일이 있을 경우,,,(filename1_b) 현재 레코드에 들어 있는 파일의 이름입니다. strFile = "c:/inetpub/wwwroot/" & filename1_b If (FSO.FileExists(strFile)) Then FSO.DeleteFile(strFile) End If 이 파일을 FSO객체를 이용해서 존재하는가를 체크를 하고 존재한다면 삭제를 해 주면 됩니다. 그리구,,, write_ok.asp 파일에서 사용했던 방법으로 자료를 서버에 저장하면 됩니다. 저장한 후에는 if Len(file1) > 0 then SQL = "Update databank set filename1 = '" & filename1 & "'" SQL = SQL & " where no = " &no Conn.Execute(SQL) end if 데이터 베이스의 내용을 수정해 주면 됩니다..... 그럼,,,, 더존 프로그램 많이 만드시길 바랍니다...
|
|||||||||||