Language/ASP | Posted by 아키텍처 2012. 4. 24. 15:28

ASP 덱스트업로드 이용한 파일저장 함수

 
 

▣ ASP 덱스트업로드 이용한 파일저장 함수

 

함수사용예제

Dim UploadForm
Set UploadForm = Server.CreateObject("DEXT.FileUpload")

Dim Juuun : Juuun = fn_FileSave (UploadForm, ReQuest로 받아온 필드명, 파일을 저장할 경로)

 

아래는 함수

Function fn_FileSave (f_UploadForm___, p_FileName___, p_FileSavePath___)

  Dim f_FilePath___, f_FileNameOnly___, f_FileExt___, f_FileName___

  f_UploadForm___.DefaultPath = p_FileSavePath___

  f_FileName___ = f_UploadForm___(p_FileName___).FileName
  f_FilePath___ = f_UploadForm___.DefaultPath & "\" & f_FileNameOnly___
  
  If f_FileName___ <> "" Then
  
   If f_UploadForm___.FileExists(f_FilePath___) Then
    
    If InStrRev(f_FileName___, ".") <> 0 Then
     f_FileNameOnly___ = Left(f_FileName___, InStrRev(f_FileName___, ".") - 1)
     f_FileExt___ = Mid(f_FileName___, InStrRev(f_FileName___, "."))
    Else
     f_FileNameOnly___ = f_FileName___
     f_FileExt___ = ""
    End If
    i = 1
    Do While (1)
     f_FilePath___ =  f_UploadForm___.DefaultPath & "\" & f_FileNameOnly___ & "[" & i & "]" & f_FileExt___
     If Not f_UploadForm___.FileExists(f_FilePath___) Then
      Exit Do
     End If
     i = i + 1
    Loop
    f_FileName___ = f_FileNameOnly___ & "[" & i & "]" & f_FileExt___
   End If

   f_UploadForm___(p_FileName___).SaveAs f_FilePath___

  Else
   f_FileName___ = ""  
  End If
  
  fn_FileSave = f_FileName___

 End Function

Posted by 김준홍 (http://www.Juuun.com)