테스트 사이트 - 개발 중인 베타 버전입니다

ASP ABCUpload4.XForm 다중 파일업로드시 파일명이 증발해버립니다. 채택완료

</p><p><%
'Dim useUTF

Dim sqlStr, goodsIMGName

Session.CodePage = 65001
response.CharSet = "UTF-8"
useUTF = True
exec_mode = request("exec_mode")
w = Request("w")
Server.ScriptTimeOut = 3600

 '파일업로드 기본 설정
 Response.Expires = -10000
 'Server.ScriptTimeOut = 300
 Set theForm = Server.CreateObject("ABCUpload4.XForm")
 theForm.Overwrite = True '같은 파일 있을 때 덮어쓰기 가능으로 설정
 theForm.MaxUploadSize = 8000000  '8M 업로드 가능
 theForm.AbsolutePath = True '절대 경로로 접근
 theForm.Maxuploadsize = 1024*1024*20
 theForm.CodePage = 65001

 Set FSO = Server.CreateObject("Scripting.FileSystemObject")
 
 dim fileName,fileSize

 

 Function GetUniqueName(strFileName, DirectoryPath)
  Dim strName, strExt
  '확장자가 없는 경우를 처리
  if InstrRev(strFileName, ".") = 0 then
   Response.write "<script language='javascript'>"
   Response.Write " alert(""적절한 파일이 아닙니다. \n\n확장자가 있는지 확인해보세요"");"
   Response.Write " history.back();"
   Response.Write "</script>"
   Response.end
  End if
  strName = Mid(strFileName, 1, InstrRev(strFileName, ".") - 1)
  strExt = Mid(strFileName, InstrRev(strFileName, ".") + 1)

  'asp파일 업로드 불가
  if strExt = "asp" or strExt = "asa" or strExt = "inc" or strExt = "bak" then
   Response.write "<script language='javascript'>"
   Response.Write " alert(""적절한 파일이 아닙니다. \n\n다시 올려주세요"");"
   Response.Write " history.back();"
   Response.Write "</script>"
   Response.end
  End if

  Dim bExist : bExist = True
  Dim strFileWholePath : strFileWholePath = DirectoryPath & "\" & strName & "." & strExt
  Dim countFileName : countFileName = 0

  Do While bExist
   If (fso.FileExists(strFileWholePath)) Then
    countFileName = countFileName + 1
    strFileName = strName & "(" & countFileName & ")." & strExt
    strFileWholePath = DirectoryPath & "\" & strFileName
   Else
      bExist = False
   End If
  Loop
  GetUniqueName = strFileWholePath
  goodsIMGName = strFileName '최종파일이름0

 End Function

 Sub Exec_fileUp(newFile,deleteFile,deleteFilesize,DirectoryPath,num)
  Set theField = newFile(num+1)
  If theField.FileExists Then           '만일 파일업을 했으면...
   strFileName = theField.SafeFileName       '파일 명
   strFileSize = theField.Length          '파일 사이즈

   '파일명을 정한다.
   strExt = Mid(strFileName, InstrRev(strFileName, ".") + 1)
   strName = Replace(Date(),"-","")  & Right(Session.SessionID,4)
   strFileName = strName & "." & strExt
   
    
    DirectoryPath = Server.MapPath(".") & "\bookstore\"
   
   if theField.Length > 8000000 then
    Response.Write "<script language=javascript>"
    Response.Write " alert(""8M 이상의 사이즈인 파일은 업로드하실 수 없습니다"");"
    Response.Write " history.back();"
    Response.Write "</script>"
    Response.end
   Else
    if Len(deleteFile) > 0 then         '삭제 화일이 있을경우..               
     delfile = DirectoryPath & "\" & deleteFile                   
     If (fso.FileExists(delfile)) Then
      fso.DeleteFile(delfile)         '파일을 지운다..
     End if
    End if
    strFileWholePath = GetUniqueName(strFileName, DirectoryPath)  '적합한 파일인지 체크한다.
    theField.Save strFileWholePath        '파일을 저장한다.
   End if
   fileUpload = strFileName
   fileSize  = strFileSize
  Else
   fileUpload = deleteFile
   fileSize  = deleteFilesize
  End If
 End Sub
 
 
'파일 업로드, 업로드 폼이 추가되면 아래 문장만 추가한다. 물론 파일명은 수정해야 한다.
CALL Exec_fileUp(theForm.item("bo_image"),"","",DirectoryPath,0)
CALL Exec_fileUp(theForm.item("bo_file1"),"","",DirectoryPath,0)
CALL Exec_fileUp(theForm.item("bo_file2"),"","",DirectoryPath,0)</p><p>

http://blog.daum.net/thecoolman/3797336%E2%80%8B" target="_blank">http://blog.daum.net/thecoolman/3797336​  

 

위 블로그를 통해 파일 업로드할 경우 서버내 저장까지는 성공하였습니다.

insert나 update 문에서 서버내 저장된 파일명을 가지고 와서 저장 시켜줘야 하는데...

goodsIMGName 이라고 할 경우, 3중 하나의 파일명의 이름만 출력이 되고 있습니다.

파일명 3개를 추출해야하는데...

 

생소한 ASP이다 보니...어려움이 많이 있습니다.

ASP 언어로 개발 경험이 있으신 선배 회원님들께 고개숙여 조언을 구해보고자 합니다.

부탁드립니다. 

 

댓글을 작성하려면 로그인이 필요합니다.

답변 1개

dim fileUpload CALL Exec_fileUp(theForm.item("bo_image"),"","",DirectoryPath,0) file1 = fileUpload CALL Exec_fileUp(theForm.item("bo_file1"),"","",DirectoryPath,0) file2 = fileUpload CALL Exec_fileUp(theForm.item("bo_file2"),"","",DirectoryPath,0) file3 = fileUpload  

 

해결했네요 ㅠㅠ 

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인

전체 질문 목록

🐛 버그신고