상세 컨텐츠

본문 제목

DEXTUpload v2.0 사용자 설명서

프로그래밍/JAVA

by 라제폰 2009. 1. 23. 17:07

본문

DEXTUpload v2.0
사용자 설명서
Copyright (c) 2000-2001 DEXT,Inc . All rights reserved. For news and updates visit
http://www.dextupload.com


목차


DEXTUpload 소개

    DEXTUpload에 대하여
    DEXTUpload 특징
    Release 정보


설치안내

    시스템 요구 사항
    최초설치
    업그레이드 설치
    DEXTUpload 제거


DEXTUpload 활용

    프로그래밍 DEXTUpload

      DEXTUpload 시작하기

      파일 업로드 기본

        간단한 업로드
        다중파일 업로드  ( Improved in v1.5 )
        다른 폼요소와 함께 업로드
        Multi-select 폼요소를 포함한 업로드 ( Improved in v1.5 )
        업로드된 파일로 부터 정보 얻기 ( Improved in v1.5 )
        이미지 파일의 폭과 높이 정보 얻기  ( New in v1.5 )
        Database BLOB필드로 업로드
        다양한 Save Method들
        파일의 존재여부 체크 및 업로드된 파일의 삭제  ( New in v1.5 )

      파일 업로드 활용

        고유한 이름으로 파일 저장
        업로드 파일 용량 제한
        업로드 타임아웃 설정
        업로드 파일 종류 제한
        외국어 및 유니코드 문자셋으로된 웹페이지에서의 사용방법  ( New in v2.0 )
        파일저장 없이도 업로드작업을 취소하는 방법  ( New in v2.0 )

      서버측 업로드 진행율 표시기 사용 ( Improved in ver. 1.5 )

      파일 다운로드

        파일 다운로드
        Database BLOB 데이터 다운로드

      서버에서의 BLOB 핸들링

        서버에 존재하는 파일을 Database BLOB에 저장
        Database BLOB필드를 서버내 파일로 저장

      DEXTUpload 에러 처리

    개체 레퍼런스

      FileUpload 개체
      FileDownload 개체
      FormItem 개체
      FileUploadMonitor 개체
      BlobManager 개체

    DEXTUpload 예제

    자주 묻는 질문들


DEXTUpload 지원


DEXTUpload
소개


■ DEXTUpload에 대하여

DEXTUpload는 웹브라우저로부터 Microsoft Internet Information Server로의 파일업로드 기능을 가진 Active Server Component입니다. 인터넷 표준인 RFC 1867을 따르고, Microsoft Active Server Pages에서 사용할 수 있습니다. 대용량 파일 업로드의 경우에도 빠른 업로드 속도와 낮은 리소스 점유율을 보이며, Server-side Graphical Progress Indicator를 통해 사용자가 업로드 진행상태를 실시간으로 모니터링할 수 있습니다.



■ DEXTUpload 특징


- Windows NT/2000 IIS 4.0이상 서버의 ASP Script에서 이용가능한 서버측 Active Server Component.

- HTML 3.2와 인터넷 표준 RFC 1867을 따름.

- Netscape 3.0 이상, Microsoft IE 4.0 이상, IE 3.02a(16bit), IE 3.02(32-bit, File Upload Add-on 필요)와 함께 작동.

- 대용량 파일 업로드 지원 및 빠른 업로드 속도와 낮은 리소스 사용 특징.
  (낮은 CPU이용률, 업로드 작업 당 순간 Memory 사용량 : 16 ∼ 64KB)

- Server-side Graphical Progress Indicator 기능. (별도의 클라이언트 소프트웨어를 다운로드받지 않고
  도 파일 업로드 진행상태를 실시간으로 모니터링할 수 있음.)

- 물리적 경로 및 가상경로로의 파일 업로드 및 다운로드 기능.

- Database BLOB으로의 파일 업로드 및 다운로드 기능
  서버 파일시스템과 Database BLOB간의 파일저장 및 추출 기능 (부가기능)

- 업로드된 이미지 파일( GIF / JPG / BMP )의 포멧, 폭, 높이 정보를 구하는 기능. ( new in ver. 1.5 )

- 외국어 및 유니코드 폼요소값, 파일명 지원 ( new in ver. 2.0 )

- 업로드 가능한 최대파일크기 제한 기능 및 업로드 Timeout (시간제한) 기능.

- 유일한 파일명으로의 저장 또는 파일 겹쳐쓰기 선택기능.

- 파일의 존재여부 체크 및 업로드된 특정 파일을 삭제할 수 있는 기능. ( new in ver. 1.5 )

- 필요에 따라 업로드된 모든 파일을 삭제할 수 있는 기능.

- 업로드 작업에 대한 무결성 보장. (업로드가 실패할 경우 사용된 모든 리소스 반환과 함께 업로드된 모든
  파일이 자동 삭제되어 무결성 보장.)

- 인코딩형식이 영어로 지정된 IE 5.0에서 다국어 사용시 발생하는 컨텐츠 이중전송 버그 자동처리.



■ Release 정보


* DEXTUpload v2.0   ( 출시일: 2001년 06월 28일 )

   [ 버그 패치 ]

   - FileSystemObject로 임의의 폴더를 생성해서 그 위치에 파일을 업로드했을 때 해당 폴더가 삭제되지 않던 버그 수정.
   - 인터넷 익스플로러 5.0 다국어 버전에서의 폼요소값 이중전송 버그를 자동처리해 주던 기능이 특정한 폼구성에서는 작동되지 않던 버그 수정.


   [ 기능 향상 ]

   - ASP Session을 무조건 사용해야만 하던 것을 Session사용여부와 무관하게 동작하도록 수정.


   [ 기능 추가 ]

   - 외국어 및 유니코드 폼요소값, 파일명 지원기능 추가 (유니코드 게시판 및 일본어, 중국어 등으로 된 웹사이트도 완벽 지원)
   - 업로드시 서버에 파일(임시파일 포함)을 전혀 저장하지 않고도 필요에 따라 파일업로드 작업을 완전히 취소(정리)할 수 있는 Flush기능 추가.



* DEXTUpload v1.5.6   ( 출시일: 2001년 02월 14일 )

   [ 버그 패치 ]

   - 웹사이트 인증방식을 익명액세스가 아닌 Windows 2000 통합인증(또는 Windows NT Challenge/Response 인증)을 사용했을 경우, 
     인터넷 익스플로러 5.0 구버전(5.00.2900.xx 이하버전)에서 에러가 발생하거나 폼요소값이 모두 Null문자열로 나오던 버그 수정.



* DEXTUpload v1.5.5   ( 출시일: 2001년 02월 12일 )

   [ 버그 패치 ]

   - DEXTUpload v1.5.4에서의 IE 5.0 다국어 버전 버그 자동처리기능 보완.


   [ 기능 추가 ]

   - 업로드되어 서버에 저장된 파일의 전체경로 및 파일명을 얻을 수 있는 LastSavedFilePath, LastSavedFileName 프로퍼티 추가.



* DEXTUpload v1.5.4   ( 출시일: 2001년 02월 06일 )

   [ 버그 패치 ]

   - 인코딩형식을 영어로 지정한 IE 5.0에서 다국어 사용시 발생하는 컨텐츠 이중전송 버그 자동처리
  - 인코딩형식을 영어로 지정한 IE 5.0에서 다국어 사용시 발생할 수 있는 첫번째 폼요소의 데이터 파싱오류 수정

* DEXTUpload v1.5.3   ( 출시일: 2000년 11월 04일 )

   [ 버그 패치 ]

   - 정확히 64K 배수 크기의 파일 다운로드시 에러가 발생하던 버그 수정


* DEXTUpload v1.5.2   ( 출시일: 2000년 10월 13일 )

   [ 버그 패치 ]
   - 영문 웹서버에 설치해서 사용할 경우 한글이 깨져서 출력되던 버그 수정


* DEXTUpload v1.5.1   ( 출시일: 2000년 9월 22일 )

   [ 버그 패치 ]
   - JPG 이미지 파일의 Width와 Height를 구하는 알고리즘의 문제로 정확한 값을 리턴하지 못하던 버그 수정
   - SaveAsBlob 호출시 uploadform("file").SaveAsBlob rs("filedata")와 같이 호출할 경우 다음과 같은 오류를 발생하던 버그 수정 
    -------------------------------------------------------------------------------------
    DEXTUpload (0x800A005B) 
    개체 변수 또는 With 문의 변수가 설정되어 있지 않습니다. 
    -------------------------------------------------------------------------------------


* DEXTUpload v1.5   ( 출시일: 2000년 9월 20일 )

   [ 버그 패치 ]
   - 폼 요소의 "name" 속성값을 지정할 때, 다른 폼 요소와 이름은 같고 대소문자만 다른 경우에 발생하던 컬렉션 키 중복 오류 수정.
   - 업로드 진행율 표시기(Progress Indicator)에서 남은 시간 및 업로드 속도 정보가 ??로 나타나던 오류 수정

  [ 기능 향상 ]
   - 업로드 진행율 표시기(Progress Indicator)를 하나의 창에 2개의 단계별 진행바를 모두 보여 주는 방식에서 각 단계별로 한 번에 하나의 진행바만 보여지도록 간소화.
   - 업로드 진행율 표시기(Progress Indicator)의 화면 Refresh에 따르는 깜박거림 현상 최소화.
   - 업로드 진행율 표시기(Progress Indicator)에서 남은 시간 및 업로드 속도계산 알고리즘 개선으로 보다 정확한 정보를 제공.
   - HTML Form요소 처리 인터페이스 향상 ( ASP의 Request.Form과 동일하게 처리가능 ).
     ( 2차원 컬렉션 지원으로 다중파일 업로드 및 Multi-select Form요소 처리 기능 향상 )

  [ 기능 추가 ]
   - 업로드된 이미지 파일( GIF / JPG / BMP )의 포멧, 폭, 높이 정보를 구하는 기능 추가 (정식판만 가능)
   - 특정 파일에 대한 존재 여부를 체크하는 메쏘드  및 파일을 삭제할 수 있는 메쏘드 추가

  [ 기타 ]
   - 업로드 진행율 표시기(Progress Indicator)에 있던 DEXTUpload 마크 제거. (정식판만 해당)
   - DEXTUpload의 버전 및 평가판의 파기일자를 알 수 있는 프로퍼티 추가



설치 안내
 

■ 시스템 요구 사항

Windows 2000 and IIS 5.0
Windows NT 4.0 and IIS 4.0 and Service Pack 5 or later.
Intel x86 Processor용 (Digital Alpha Processor는 지원하지 않습니다.)



최초설치

간단히 DEXTUpload 설치프로그램을 이용해서 설치하시면 됩니다. 
이 때, 설치과정에서 IIS관련 서비스를 재시작할 것인지 여부를 묻게 되는데, 최초 설치의 경우는 서비스를 재시작하지 않아도 상관없으므로 '아니오'를 클릭한 후 설치를 계속 진행하시면 됩니다.

설치프로그램을 이용하여 DEXTUpload 컴포넌트를 설치한 후, Sample을 테스트해 보고자 할 경우에는 다음과 같은 추가적인 작업이 필요합니다.

1) IIS Web root 하위에 "DEXTUploadSamples"라는 이름의 가상 디렉토리를 만듭니다.
2) 생성한 가상 디렉토리를 DEXTUpload와 함께 설치된 "Samples" 폴더에 연결합니다.
3) "Samples"의 하위 폴더인 "DATA" 폴더에 쓰기 권한을 부여합니다. 이 때, "DATA" 폴더는 가상경로로의 업로드 예제에서 업로드된 파일이 저장되는 곳입니다.
4) ODBC 데이터 원본 관리자에서 "DEXTUPLOAD"라는 이름의 DSN을 추가하고 "Samples" 폴더에 있는 dextupload.mdb 파일을 지정합니다. dextupload.mdb 파일은 데이터베이스 관련 예제 수행을 위해 필요합니다.



■ 업그레이드 설치

아래에 설명된 "DEXTUpload 제거" 절차에 따라 일단, 기존에 설치된 DEXTUpload 컴포넌트를 완전히 제거합니다.

그런 다음, DEXTUpload 업그레이드 버전의 설치프로그램을 이용해서 새롭게 설치하시면 됩니다.
이 때, 설치과정에서 최초설치와 마찬가지로 IIS관련 서비스의 재시작 여부를 묻게 되는데, 서버를 리부팅하거나 IIS가 시작된 이후 DEXTUpload 컴포넌트를 사용하는 ASP페이지를 전혀 호출한 적이 없는 경우에만 '아니오'를 클릭하시고, 그것이 확실치 않다면 '예'를 클릭해서 IIS를 재시작시켜 주어야 컴포넌트가 정상적으로 설치됩니다.

주의 ) 설치프로그램을 이용하지 않고 단순히 Regsvr32.exe를 이용해서 컴포넌트 DLL ( DEXTUpload.dll  )만 윈도우 레지스트리에 등록할 경우 컴포넌트가 정상적으로 작동하지 않습니다. 반드시 설치프로그램을 이용해서 설치하시기 바랍니다.



■ DEXTUpload 제거


제어판의 프로그램 추가삭제 기능을 이용하거나, 컴포넌트 설치시 윈도우 시작메뉴에 만들어진 "UnInstall DEXTUpload"메뉴를 클릭하시면  컴포넌트를 언인스톨할 수 있습니다.

단, 이 때,  DEXTUpload.dll 파일이 IIS에 의해 참조되고 있는 경우에는 이 파일을 삭제할 수 없기 때문에 언인스톨 작업이 정상적으로 수행되지 않습니다. 따라서, 이런 경우에는 시스템을 리부팅하거나 IIS를 재시작시킨 다음 언인스톨을 수행하시면 됩니다.





DEXTUpload 활용


■ 프로그래밍 DEXTUpload


* DEXTUpload 시작하기

DEXTUpload 컴포넌트는 Windows NT/2000 IIS 4.0 이상의 ASP(Active Server Pages) 스크립트 내에서
이용할 수 있습니다. Database로의 업로드 및 다운로드는 ADO(ActiveX Data Objects)를 이용해서 구현됩니다.
본 Guide는 컴포넌트의 주요 기능들에 대한 사용방법을 설명하고 있으며, 세부적인 프로그래밍 내용에 대해서는 제공된 Sample 예제들을 참고하시기 바랍니다.



* 파일 업로드 기본


- 간단한 업로드

전송할 Form이 있는 페이지(SimpleUpload.asp)는 다음과 같은 형태로 작성된다.

[SimpleUpload.asp]
<HTML>
<BODY>
<FORM NAME="writeform" METHOD="post" ACTION="SU_Process.asp" ENCTYPE="multipart/form-data">
<INPUT TYPE="file" NAME="file1"><BR>
<INPUT TYPE="submit" VALUE="upload">
</FORM>
</BODY>
</HTML>

Form tag에 지정된 ENCTYPE="multipart/form-data" 는 파일데이터<input type="file">를 포함하고 있는 폼을 전송하기 위해서 반드시 필요한 속성으로서 생략될 수 없다.
다음은 실제로 파일 업로드 등의 작업을 수행하는 페이지(SU_Process.asp)이다.

[SU_Process.asp]
<%@ LANGUAGE="VBSCRIPT"%>
<HTML>
<BODY>
<%
Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "C:\Temp"

uploadform.Save ' uploadform("file1").Save 라고 해도 됨.
Set uploadform = Nothing
%>
</BODY>
</HTML> 

위 코드에 따라 업로드된 파일은 디폴트 경로인 "c:\"에 저장된다. 디폴트 경로를 바꾸고 싶으면 개체 생성코드 다음 위치에 uploadform.DefaultPath = "c:\temp" 와 같은 코드를 넣어주면 된다. uploadform.Save는 업로드 된 파일을 서버에 디스크파일 형태로 저장하는 것으로 uploadform("file1").Save와 같다. 여기서 "file1"은 <INPUT TYPE="file" NAME="file1">에서의 NAME속성에 해당되는 이름과 같아야 한다. Save함수들에 대한 자세한 설명은 아래에 있는 "다양한 Save Method들" 장에 기술되어 있다.

※ 아래 "Multiple Upload" 예제에서 처럼 <INPUT TYPE="file"...> 항목이 여러 개일 경우,uploadform.Save, uploadform.SaveAs, uploadform.SaveVirtual, uploadform.SaveAsVirtual, uploadform.SaveAsBlob,
uploadform.FileLen, uploadform.FileName, uploadform.FilePath, uploadform.MimeType 과 같은 표현 은 모두 uploadform("file1").xxx 와 동일한 표현이며, 여러 개의 <<INPUT TYPE="file"...>항목 중 첫 번
째 파일항목을 가리킨다.



- 다중파일 업로드 ( Improved in v 1.5 )

다음 예제는 여러 개의 파일을 동시에 업로드하는 방법을 보여주고 있다.

[MultipleUpload.asp]
<HTML>
<BODY>
<FORM NAME="writeform" METHOD="post" ACTION="MU_Process.asp" ENCTYPE="multipart/form-data">
<INPUT TYPE="file" NAME="file1"><BR>
<INPUT TYPE="file" NAME="file2"><BR>
<INPUT TYPE="file" NAME="file3"><BR>
<INPUT TYPE="submit" VALUE="upload">
</FORM>
</BODY>
</HTML>

[MU_Process.asp]
<%@ LANGUAGE="VBSCRIPT"%>
<HTML>
<BODY>
<%
Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "c:\temp"

uploadform("file1").Save ' uploadform.Save라고 해도 됨
uploadform("file2").Save
uploadform("file3").Save
Set uploadform = Nothing
%>
</BODY>
</HTML>

업로드된 파일들에 대한 참조는 "file1", "file2", "file3"와 같은 NAME 속성값들을 통해서 이루어진다.
또 다른 방법으로, 여러 INPUT항목들의 NAME 속성을 동일한 값으로 지정한 다음 반복문을 이용해서 한꺼번에 저장할 수도 있다. 다음은 이를 보여주는 예제이다.

[MultipleUpload2.asp]
<HTML>
<BODY>
<FORM NAME="writeform" METHOD="post" ACTION="MU_Process.asp" ENCTYPE="multipart/form-data">
<INPUT TYPE="file" NAME="files"><BR>
<INPUT TYPE="file" NAME="files"><BR>
<INPUT TYPE="file" NAME="files"><BR>
<INPUT TYPE="submit" VALUE="upload">
</FORM>
</BODY>
</HTML>

[MU_Process2.asp]
<%@ LANGUAGE="VBSCRIPT"%>
<HTML>
<BODY>
<%
Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "c:\temp"

For i = 1 To uploadform("files").Count
  uploadform("files")(i).Save
Next

Set uploadform = Nothing
%>
</BODY>
</HTML>


위 예제에서 For문을 다음과 같이 작성해도 동일한 결과를 얻을 수 있다.

For Each item In uploadform("files")
  item.Save
Next




- 다른 폼요소와 함께 업로드


Form의 다른 요소들도 파일요소와 마찬가지로 NAME 속성값을 통해서 참조할 수 있다.

[UploadElements.asp]
<HTML>
<BODY>
<FORM NAME="writeform" METHOD="post" ACTION="UE_Process.asp" ENCTYPE="multipart/form-data">
<INPUT TYPE="text" NAME="title"><BR>
<TEXTAREA NAME="content" ROWS="10" COLS="50"></TEXTAREA><BR>
<INPUT TYPE="file" NAME="file1"><BR>
<INPUT TYPE="submit" VALUE="upload">
</FORM>
</BODY>
</HTML>

[UE_Process.asp]
<%@ LANGUAGE="VBSCRIPT"%>
<HTML>
<BODY>
<%
Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "c:\temp"

title = uploadform("title")
content = uploadform("content")
uploadform("file1").Save
Set uploadform = Nothing
%>
</BODY>
</HTML>



 

- Multi-select 폼요소를 포함한 업로드 ( Improved in v1.5 )

DEXTUpload는 ListBox, Radio button 등과 같이 하나의 Name 속성에 대해 여러 Value값들을 가질 수 있는 Multi-select 폼 요소들을 처리할 때, Request.Form을 쓰는 것처럼 편리하게 이를 처리할 수 있다.

[UploadMultiElements.asp]
<HTML>
<BODY>
<FORM NAME="writeform" METHOD="post" ACTION="UE_Process.asp" ENCTYPE="multipart/form-data">
<H2>Select your favorite sports</H2>
<SELECT NAME="Sports" MULTIPLE>
<OPTION VALUE="Soccer">Soccer</OPTION>
<OPTION VALUE="Baseball">Baseball</OPTION>
<OPTION VALUE="basketball">Basketball</OPTION>
</SELECT><BR>
<INPUT TYPE="file" NAME="DescFile"><BR>
<INPUT TYPE="submit" VALUE="upload">
</FORM>
</BODY>
</HTML>


[UME_Process.asp]
<%@ LANGUAGE="VBSCRIPT"%>
<HTML>
<BODY>
<%
Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "c:\temp"

Response.Write "Your favorite sports :<br>"

For i = 1 To uploadform("Sports").Count
  Response.Write "-" & uploadform("Sports")(i) & "<br>"

Next

uploadform("DescFile").Save
Set uploadform = Nothing
%>
</BODY>
</HTML>


위 예제에서 For문을 다음과 같이 작성해도 동일한 결과를 얻을 수 있다.

For Each item In uploadform("Sports")
  Response.Write "-" & item & "<br>"
Next




- 업로드된 파일로 부터 정보 얻기

업로드된 파일에 대한 정보를 얻을 수 있도록 다음과 같은 Property들이 제공된다.

.FileLen : 업로드된 파일의 길이
.FileName : 업로드된 파일의 이름(경로제외)
.FilePath : 업로드된 파일의 전체경로
.MimeType : 업로드된 파일의 Mime Type
.LastSavedFileName : 업로드되어 실제로 서버에 저장된 파일의 이름(경로제외)
.LastSavedFilePath : 업로드되어 실제로 서버에 저장된 파이의 전체경로

※ .FileName과 .FilePath는 사용자가 업로드한 오리지널 파일에 대한 이름과 전체경로값을 가진다.
업로드되어 서버에 저장된 파일의 전체경로값은 .Save, .SaveAs Method 등의 리턴값으로부터 얻을 수 있다.

[Form_Process.asp]
<%@ LANGUAGE="VBSCRIPT"%>
<HTML>
<BODY>
<%
Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "d:\upload"

Response.Write "[Uploaded File Information] <BR>"
Response.Write "FileName : " & uploadform("file1").FileName & "<BR>"
Response.Write "FullPath : " & uploadform("file1").FilePath & "<BR>"
Response.Write "FileLength : " & uploadform("file1").FileLen & " Byte(s)<BR>"
Response.Write "MimeType : " & uploadform("file1").MimeType & "<BR>"

uploadedpath = uploadform("file1").Save
Response.Write "UploadedPath : " & uploadedpath & "<BR>"
Response.Write "LastSavedFilePath : " & uploadform("file1").LastSavedFilePath & "<BR>"
Response.Write "LastSavedFileName : " & uploadform("file1").LastSavedFileName

Set uploadform = Nothing
%>
</BODY>
</HTML> 

위 페이지가 실행된 결과는 다음과 같은 형태로 나타날 것이다.

[Uploaded File Information]
FileName : sample.jpg
FullPath : c:\data\sample.jpg
FileLength : 176816 Byte(s)
MimeType : image/pjpeg
UploadedPath : d:\upload\sample.jpg
LastSavedFilePath : d:\upload\sample.jpg
LastSavedFileName : sample.jpg




- 이미지 파일(GIF/JPG/BMP)의 폭과 높이 정보 얻기
( new in ver. 1.5 )

업로드된 파일이 이미지 파일(GIF/JPG/BMP)인 경우 다음과 같이 이미지의 폭과 높이 정보 등을 얻을 수 있는 추가적인 Property들이 제공된다.

.ImageFormat : 업로드된 이미지 파일의 포멧
.ImageWidth  : 업로드된 이미지 파일의 폭
.ImageHeight : 업로드된 이미지 파일의 높이

[Form_Process.asp]
<%@ LANGUAGE="VBSCRIPT"%>
<HTML>
<BODY>
<%
Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "c:\temp"

Response.Write "[Uploaded Image File Information] <BR>"
Response.Write "FileName : " & uploadform("file1").FileName & "<BR>"
Response.Write "FullPath : " & uploadform("file1").FilePath & "<BR>"
Response.Write "FileLength : " & uploadform("file1").FileLen & " Byte(s)<BR>"
Response.Write "MimeType : " & uploadform("file1").MimeType & "<BR>"
Response.Write "ImageFormat : " & uploadform("file1").ImageFormat & "<BR>"
Response.Write "ImageWidth : " & uploadform("file1").ImageWidth & "<BR>"
Response.Write "ImageHeight : " & uploadform("file1").ImageHeight & "<BR>"


uploadedpath = uploadform("file1").Save
Response.Write "UploadedPath : " & uploadedpath
Set uploadform = Nothing
%>
</BODY>
</HTML> 

위 페이지가 실행된 결과는 다음과 같은 형태로 나타날 것이다.

[Uploaded Image File Information]
FileName : sample.jpg
FullPath : c:\data\sample.jpg
FileLength : 176816 Byte(s)
MimeType : image/pjpeg
ImageFormat : JPG
ImageWidth : 1024
ImageHeight : 768

UploadedPath : c:\temp\sample.jpg


 



- Database BLOB필드로 업로드

다음과 같이 SaveAsBlob Method를 이용하면 파일을 업로드하여 Database BLOB필드로 저장할 수 있다.

[Form_Process.asp]
<%@ LANGUAGE="VBSCRIPT"%>
<HTML>
<BODY>
<%
Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "c:\temp"

Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open"SampleTable","DSN=SampleDSN;UID=sa;PWD=xxx;", 3, 3
rs.AddNew
rs("filename") = uploadform("file1").FileName
rs("mimetype") = uploadform("file1").MimeType
uploadform("file1").SaveAsBlob rs("filedata")
rs.Update

rs.Close
Set rs = Nothing
Set uploadform = Nothing
%>
</BODY>
</HTML>

※ DEXTUpload 컴포넌트가 제공하는 Database BLOB관련 Method로는 다음과 같은 것들이 있다.
FileUpload 개체의 SaveAsBlob : 파일을 업로드하여 Database BLOB 필드에 저장한다.
FileDownload 개체의 DownloadBlob : Database BLOB을 사용자의 디스크로 다운받아 파일로 저장한다.
BLOBManager 개체의 SaveFileAsBlob : 서버에 존재하는 파일을 Database BLOB필드에 저장한다.
BLOBManager 개체의 SaveBlobAsFile : Database BLOB을 서버의 디스크 파일로 저장한다.




- 다양한 Save Method들

DEXTUpload 컴포넌트는 업로드된 파일을 서버 파일시스템 또는 Database에 저장할 수 있는 다양한 방법을 제공한다.
* 업로드된 파일과 같은 이름의 파일로 서버에 저장하는 Method
- Save : DefaultPath property값으로 지정된 경로에 저장
- Save [Path지정] : 지정된 경로에 저장
- SaveVirtual [Virtual Path지정] : 지정된 가상경로에 저장

* 업로드된 파일과 다른 이름의 파일로 서버에 저장하는 Method
- SaveAs [Full Path지정] : 지정된 경로와 파일명으로 저장
- SaveAsVirtual [Full Virtual Path지정] : 지정된 가상경로와 파일명으로 저장

* 업로드된 파일을 Database BLOB필드에 저장하는 함수
- SaveAsBlob [ADO Field개체지정] : 지정된 Database BLOB필드에 저장

※ SaveAsBlob을 제외한 나머지 모든 Save Method들은 bOverwrite 라는 인자와 실제로 서버에 저장되는 파일에 대한 전체경로를 리턴값으로 가진다. bOverwrite 인자를 생략할 경우 기본값은 True이며 해당 경로에 같은 이름의 파일이 있을 경우 겹쳐쓰게 된다. bOverwrite 인자값을 명시적으로 False로 지정할 경우는 유일한 파일명( filename(2).ext, filename(3).ext ... )을 구해서 저장하게 된다.




- 파일의 존재여부 체크 및 업로드된 파일의 삭제
( New in v1.5 )

DEXTUpload는 파일의 존재여부를 체크할 수 있는 FileExists 메쏘드와 업로드된 파일을 삭제할 수 있는 DeleteFile 메쏘드를 제공한다. 다음은 FileExists와 SaveAs 메쏘드를 이용하여 업로드한 파일을 서버에 고유한 파일명으로 저장하는 예제이다. 

[Form_Process.asp]
<%@ LANGUAGE="VBSCRIPT"%>
<HTML>
<BODY>
<%
Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "c:\temp"

filename = uploadform("file1").FileName
filepath = uploadform.DefaultPath & "\" & filename

If uploadform.FileExists(filepath) Then

    ' Get FileName and FileExt
   
If InStrRev(filename, ".") <> 0 Then
        filenameonly = Left(filename, InStrRev(filename, ".") - 1)
        fileext = Mid(filename, InStrRev(filename, "."))
     Else
        filenameonly = filename
        fileext = ""
     End If

     ' Get Unique FileName
    
i = 2
    Do While (1)
        filepath = uploadform.DefaultPath & "\" & filenameonly & "[" & i & "]" & fileext
        If Not uploadform.FileExists(filepath) Then Exit Do
        i = i + 1
    Loop
End If

uploadform("file1").SaveAs filepath

' If you want to delete this file
' uploadform.DeleteFile filepath

Set uploadform = Nothing

%>
</BODY>
</HTML>

※ DEXTUpload는 파일을 고유한 이름으로 저장할 수 있는 기능을 기본적으로 제공한다. 위 예제는 단지 DEXTUpload가 제공하는 방식이 아니라 사용자 나름대로의 방식대로 고유한 파일명을 결정하고자 할 경우의 예를 보여준 것이다.

 



* 파일 업로드 활용



- 고유한 이름으로 파일 저장

Save, SaveVirtual, SaveAs, SaveAsVirtual Method는 기본적으로 업로드된 파일을 서버에 저장할 때 해당 경로에 동일한 이름의 파일이 존재할 경우 겹쳐쓰게 된다. 겹쳐쓰지 않고 유일한 파일명을 구해서 저장하고 싶으면 두 번 째 인자인 bOverwrite를 명시적으로 False로 지정하면 된다. ("다양한 Save Method들" Chapter 참조)

[Form_Process.asp]
<%@ LANGUAGE="VBSCRIPT"%>
<HTML>
<BODY>
<%
Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "c:\temp"

uploadedfile = uploadform.SaveAs("c:\data\sample.zip", False)
Response.Write "uploaded file : " & uploadedfile
Set uploadform = Nothing
%>
</BODY>
</HTML>

위 예제에서 c:\data 폴더에 sample.zip이라는 파일이 이미 존재할 경우 업로드된 파일은 "c:\data\sample(2).zip"
이라는 이름으로 저장되어 다음과 같은 결과 페이지를 보여주게 된다.

[ 실행결과 ]
uploaded file : c:\data\sample(2).zip



- 업로드 파일 용량 제한

MaxFileLen property를 이용하면 업로드 가능한 최대 파일 크기를 제한할 수 있다. 만일 지정된 크기보다 큰 파일 을 업로드 할 경우에는 다음과 같은 오류가 발생하게 된다.

DEXTUpload error '80040200'
Warning: File size must be less than 5242880 Bytes.
/form_process.asp, line 27

다음 예제와 같이 FileLen property를 이용해서 최대 파일 크기를 초과하지 않는 경우에만 Save Method를 호출하게 하는 방법으로 오류발생 없이 업로드 파일크기 제한에 대한 처리를 커스터마이징 할 수도 있다.

[Form_Process.asp]
<%@ LANGUAGE="VBSCRIPT"%>
<HTML>
<BODY>
<%
Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "c:\temp"
uploadform.MaxFileLen = 5242880

If uploadform("file1").FileLen > uploadform.MaxFileLen Then
   Response.Write "File size must be less than 5MBytes.<br>"
   Response.Write "Press the back button on your browser...<br>"
Else
   uploadform("file1").Save
End If
Set uploadform = Nothing
%>
</BODY>
</HTML>



- 업로드 타임아웃 설정

일반적으로 파일 업로드 또는 Save 등과 같은 작업은 대용량 파일 업로드시 긴 시간을 요하므로 Server.ScriptTimeout(Default: 90sec)과 Session.Timeout(Default: 20min) 값을 바꾸어 주지 않을 경우 Timeout 에러로 인해 업로드 작업을 정상적으로 수행할 수 없게 된다.

DEXTUpload는 UploadTimeout property를 제공함으로써, 파일 업로드시 별도의 Server.ScriptTimeout, Session.Timeout 설정을 하지 않고도 Timeout에러 없이 대용량 파일 업로드 작업을 정상적으로 수행할 수 있다. 기본 값은 3600sec(60min)이고 필요에 따라 변경해서 사용하면 된다.

[Form_Process.asp]
<%@ LANGUAGE="VBSCRIPT"%>
<HTML>
<BODY>
<%
Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "c:\temp"
uploadform.UploadTimeout = 1800

uploadform.Save
Set uploadform = Nothing
%>
</BODY>
</HTML> 

위 예제에서는 UploadTimeout값을 1800sec(30min)로 설정했으므로, Save작업이 1800sec를 초과하지 않는 한 Timeout에러가 발생하지 않는다.



- 업로드 파일 종류 제한

DEXTUpload가 제공하는 MimeType property를 이용하면 업로드 가능한 파일의 종류를 제한할 수 있다.
다음은 GIF와 JPG 파일만 업로드할 수 있도록 하는 예제이다.

[Form_Process.asp]
<%@ LANGUAGE="VBSCRIPT"%>
<HTML>
<BODY>
<%
Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "c:\temp"

mimetype = uploadform("file1").MimeType
If mimetype="image/gif" or mimetype="image/pjpeg" Then
   uploadform("file1").Save
Else
   Response.Write "Your file must be GIF or JPG...<br>"
End If

Set uploadform = Nothing
%>
</BODY>
</HTML>



- 외국어 및 유니코드 문자셋으로된 웹페이지에서의 사용방법 ( New in v2.0 )


DEXTUpload가 제공하는 CodePage property를 이용하면 외국어 및 유니코드로된 폼요소값 및 파일명의 처리가 가능하다.
다음은 유니코드 문자셋을 사용하는 웹페이지에서 DEXTUpload를 사용하는 예제이다.

[Form.asp]
<%@ LANGUAGE="VBSCRIPT"%>
<%
old_codepage = Session.CodePage
Session.CodePage = "65001"

%>

<HTML>
<HEAD>
<
META http-equiv="Content-Type" content="text/html; charset=utf-8"
>
</HEAD>
<BODY>
 
<
FORM name="upform" method="post" action="form_proc.asp" enctype="multipart/form-data"
>
<INPUT type="text" name="title"><br>
<INPUT type="file" name="upfile"><br>
<INPUT type="submit" name="submit" value="send">
</FORM>

</BODY>
</HTML>
<%
Session.CodePage = old_codepage
%>



[Form_Proc.asp]
<%@ LANGUAGE="VBSCRIPT"%>
<%
old_codepage = Session.CodePage
Session.CodePage = "65001"

%>

<META http-equiv="Content-Type" content="text/html; charset=utf-8" >

<%

Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "D:\Temp"
uploadform.CodePage = 65001

Response.Write "title: " & uploadform("title") & "<BR>"
Response.Write "filename: " & uploadform("upfile").FileName
uploadform.Save

Set uploadform = Nothing
Session.CodePage = old_codepage
%>
 



- 파일저장 없이도 업로드작업을 취소하는 방법 ( New in v2.0 )


DEXTUpload가 제공하는 Flush method를 이용하면 실제로 파일을 서버에 저장하지 않고도
필요에 따라 업로드 작업을 완전히 취소하고 나머지 코드를 계속 실행하도록 할 수 있다.
다음은 파일 업로드시 제한된 업로드 용량을 초과할 경우 업로드를 취소하고 에러메시지
를 보여주는 예제이다.

[Form_Proc.asp]
<%@ LANGUAGE="VBSCRIPT"%>
<%
Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "D:\Temp"

If Request.TotalBytes > 1048576 Then 
      uploadform.Flush
      Response.Write "Warning: File size must be less than 1 MBytes."
Else
      uploadform.Save
      Response.Write "File-upload completed."
End If

Set uploadform = Nothing
%>





* 서버측 업로드 진행율 표시기 사용 ( Improved in v1.5 )

Server-side Graphical Progress Indicator를 이용하면 ActiveX Control이나 Java Applet과 같은 별도의 Client-side 소프트웨어를 다운로드 받지 않고도 단지 서버측 컴포넌트만으로 파일 업로드 진행상태를 시각적으로 보여주고, 업로드 속도, 전체 컨텐츠의 크기 및 현재 업로드된 컨텐츠의 크기, 남은 시간, 현재 진행되고 있는 작업 등의 정보를 실시간으로 모니터링할 수 있다.

이 기능은 FileUploadMonitor개체를 통해서 구현되며 다음과 같은 두 개의 Method가 제공된다.
UseMonitor : Form을 작성하는 페이지에서 호출되며, Progress Indicator의 모니터링 기능을 켠다.
ShowMonitor : Progress Indicator를 보여주는 페이지(창)에서 호출되며, 업로드 진행상태를 시각적으로 보여준다.

[ Form 작성 페이지 (GPIUpload.asp) ]

<%@ LANGUAGE="VBSCRIPT"%>
<%
Set objMon = Server.CreateObject("DEXT.FileUploadMonitor")
objMon.UseMonitor(True)
Set objMon = Nothing
%>

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--

function ShowProgress()
{
   strAppVersion = navigator.appVersion;
   if (document.writeform.file1.value != "") {

      if (strAppVersion.indexOf('MSIE')!=-1 && 
          strAppVersion.substr(strAppVersion.indexOf('MSIE')+5,1) > 4) {

          winstyle = "dialogWidth=385px; dialogHeight:150px; center:yes"; 
          window.showModelessDialog("show_progress.asp?nav=ie", null, winstyle);
      }
      else 
          winpos = "left=" + ((window.screen.width-380)/2)+",top=" +
               ((window.screen.height-110)/2);

          winstyle = "width=380,height=110,status=no,toolbar=no,menubar=no," + 
               "location=no,
resizable=no,scrollbars=no,copyhistory=no," + winpos;
          window.open("show_progress.asp",null,winstyle);
      } 
   }

   return true;
}

//-->
</SCRIPT>
</HEAD>

<BODY>
<FORM NAME="writeform" METHOD="post" ACTION="form_process.asp" 
   ENCTYPE="multipart/form-data"
onSubmit="return ShowProgress();">

<INPUT TYPE="file" NAME="file1"><BR>
<INPUT TYPE="submit" VALUE="upload">
</FORM>
</BODY>
</HTML>


Progress Indicator를 사용하기 위해서는 위 예제와 같이 Form 작성 페이지 상단에서 FileUploadMonitor개체의 UseMonitor Method를 True를 인자로 해서 호출해야한다. 만일 UserMonitor Method를 호출하지 않거나 False를 인자로 해서 호출하게 되면 Progress Indicator 기능을 사용하지 않는 것으로 간주된다. 위 예제를 보면 Form을 Submit하기 직전에 ShowProgress()라는 함수를 호출하여 Progress Indicator를 시각적으로 보여주기 위해 새 창(또는 대화상자)을 띄워 주는 것을 볼 수 있다.
이 때, 새 창에서 보여지는 페이지는 다음과 같다.

[ Progress Indicator를 보여주는 페이지 (show_progress.asp) ]

<%@ EnableSessionState=False%>

<%
'Case of Netscape Navigator
If Request("nav") = "ns" Then

%>
  
<frameset rows="80,1*" border="0" framespacing="0" frameborder="no">
   <frame src="show_prog_body.asp" noresize scrolling="NO" frameborder="NO"
       name="sp_body">
   <frame src="show_prog_bottom.asp" noresize scrolling="NO" frameborder="NO"
      name="sp_bottom">

<%
'Case of Internet Explorer
Else
%>
   <HTML>
   <HEAD>
   <TITLE>Uploading Files...</TITLE>
   <STYLE type="text/css">
       td {font-size: 9pt}
   </STYLE>
   </HEAD>

   <BODY bgcolor="#d4d0c8" leftmargin="8" topmargin="0" scroll="no">
  
<IFRAME src="show_prog_body.asp" title="Progress Step1" frameborder=0
       marginheight=0 marginwidth=0 noresize scrolling=no width=365 height=65>
   </IFRAME>
<BR><BR>

   <TABLE border="0" width="365" cellpadding="2" cellspacing="0" bgcolor="#d4d0c8">
   <TR><TD>Click the <B>STOP</B> button on your browser to abort uploading.</TD></TR>
   </TABLE>

   </BODY>
   </HTML>
<%
End If
%>


Progress Indicator를 보여주기 위해서는 위에 있는 show_progress.asp와 함께 다음에 있는 show_prog_body.asp와 show_prog_bottom.asp가 필요하다.
1) show_progress.asp: Progress Indicator를 보여주기 위해 웹페이지를 프레임으로 나눈다.
2) show_prog_body.asp: 실제로 Progress Indicator를 보여주는 역할을 한다.
3) show_prog_bottom.asp: (Netscape Navigator와 같이 Inline Frame을 지원하지 않는 브라우저의 경우만 필요)

[ Progress Indicator를 보여주는 페이지 (show_prog_body.asp) ]

<%@ EnableSessionState=False%>
<%
Set m_objMon = Server.CreateObject("DEXT.FileUploadMonitor")
m_objMon.ShowMonitor
Set m_objMon = Nothing
%>


[ Progress Indicator를 보여주는 페이지 (show_prog_bottom.asp) ]

<%@ EnableSessionState=False%>
<HTML>
<HEAD>
<STYLE type="text/css">
td {font-size: 9pt }
</STYLE>
</HEAD>

<BODY bgcolor="#d4d0c8" leftmargin="8" topmargin="0" scroll="no">
<TABLE border="0" width="365" cellpadding="2" cellspacing="0" bgcolor="#d4d0c8">
<TR><TD>Click the <B>STOP</B> button on your browser to abort uploading.</TD></TR>
</TABLE>
</BODY>
</HTML>


위 ASP 페이지를 보면 "EnableSessionState" 속성을 False로 지정하여 세션상태를 해제하고 있다. 만일 이 페이지의 세션상태를 해제하지 않으면 Form의 submit 작업, 즉 파일 업로드 작업이 종료되기 전까지는 페이지의 실행된 결과를 볼 수 없게 되므로 반드시 페이지의 세션상태를 해제시켜야 한다. ShowMonitor Method는 매 순간의 업로드 진행상태를 보여주고 업로드가 완료되면 자동으로 창(또는 대화상자)을 닫는다.


[ 업로드 작업을 처리하는 페이지 (form_process.asp) ]

<%@ LANGUAGE="VBSCRIPT"%>
<HTML>
<BODY>
<%
Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "c:\temp"

uploadform("file1").Save
Set uploadform = Nothing
%>
</BODY>
</HTML>

업로드 작업을 처리하는 페이지는 Progress Indicator의 사용여부에 관계없이 동일하게 작성해 주면 된다.





* 파일 다운로드


- 파일 다운로드

FileDownload개체의 Download, DownloadVirtual Method는 서버에 있는 파일을 웹브라우저를 통해 사용자가 다운
로드 받을 수 있게 한다.
Download : 서버의 지정된 경로에 있는 파일을 다운로드 한다.
DownloadVirtual : 서버의 지정된 가상경로에 있는 파일을 다운로드 한다.


[Download.asp]

<%@ Language=VBScript %>
<%
Response.Buffer = False
filepath = Request.QueryString("file")
filename = Mid(filepath, InStrRev("\")+1)

Response.AddHeader "Content-Disposition","inline;filename=" & filename

set objFS = Server.CreateObject("Scripting.FileSystemObject")
set objF = objFS.GetFile(filepath)
Response.AddHeader "Content-Length", objF.Size
set objF = nothing
set objFS = nothing

Response.ContentType = "application/x-msdownload"
Response.CacheControl = "public"

Set objDownload = Server.CreateObject("DEXT.FileDownload")
objDownload.Download filepath
Set uploadform = Nothing
%>

다운로드할 파일의 전체경로와 함께 상기 ASP페이지를 실행하면 해당 파일을 다운로드 받을 수 있게 된다. 페이지
상단을 보면 Response.Buffer = False 로 지정하여 버퍼링 없이 즉시 파일을 다운로드 받을 수 있게 했고, Content-
Disposition, Content-Length, ContentType 등의 헤드정보를 지정한 후 Download Method를 호출하고 있다. 사용자는
웹브라우저에 나타나는 대화상자에 다운로드할 경로와 파일명을 지정하여 다운로드 받을 수 있다.




- Database BLOB 데이터 다운로드

FileDownload개체의 DownloadBlob Method는 서버에 있는 Database BLOB을 웹브라우저를 통해 사용자의 디스크
파일로 다운로드 받을 수 있게 한다. Database 관련부분을 제외하고는 Download Method와 사용법이 동일하다.


[ DownloadBlob.asp ]

<%@ Language=VBScript %>
<%
Response.Buffer = False
Set rs = Server.CreateObject("ADODB.Recordset")
strQuery = "SELECT * FROM SampleTable WHERE id = " & Request.QueryString("id")
rs.Open strQuery, "DSN=SampleDSN;UID=sa;PWD=xxx;", 3, 1

Response.AddHeader "Content-Disposition","inline;filename=" & rs("filename")
Response.AddHeader "Content-Length", rs("fildata").ActualSize

Response.ContentType = "application/x-msdownload"
Response.CacheControl = "public"

Set objDownload = Server.CreateObject("DEXT.FileDownload")
objDownload.DownloadBlob rs("filedata")
Set uploadform = Nothing

rs.Close
Set rs = Nothing
%>





* 서버에서의 BLOB 핸들링

DEXTUpload는 서버 내에서의 Database BLOB 처리를 위해 BlobManager라는 개체를 추가로 제공하는데, 다음과 같은
두 개의 Method를 가지고 있다.
SaveFileAsBlob : 서버에 존재하는 파일을 Database BLOB필드에 저장한다.
SaveBlobAsFile : Database BLOB을 서버에 디스크 파일형태로 저장한다.


- 서버에 존재하는 파일을 Database BLOB에 저장

다음은 서버의 c:\data라는 폴더에 존재하는 sample.zip이라는 파일을 Database BLOB필드에 저장하는 예이다.

[ FileToBlob.asp ]

<%@ Language=VBScript %>
<%
Ser blobman = Server.CreateObject("DEXT.BlobManager")
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "SampleTable", "DSN=SampleDSN;UID=sa;PWD=xxx;", 3, 3

rs.AddNew
rs("filename") = "sample.zip
blobman.SaveFileAsBlob "c:\data\sample.zip", rs("filedata")
rs.Update

rs.Close
Set rs = Nothing
Set blobman = Nothing
%>



- Database BLOB 필드를 서버내 파일로 저장

다음은 Database BLOB을 서버에 디스크 파일형태로 저장하는 예이다.

[ BlobToFile.asp ]

<%@ Language=VBScript %>
<%
Ser blobman = Server.CreateObject("DEXT.BlobManager")
Set rs = Server.CreateObject("ADODB.Recordset")
strQuery = "SELECT * FROM SampleTable WHERE id = 100"
rs.Open strQuery, "DSN=SampleDSN;UID=sa;PWD=xxx;", 3, 1

filename = "c:\data\" & rs("filename")
blobman.SaveBlobAsFile rs("filedata"), filename

rs.Close
Set rs = Nothing
Set blobman = Nothing
%>





* DEXTUpload 에러 처리

DEXTUpload 컴포넌트에서 발생되는 모든 오류는 Err개체를 통해서 체크할 수 있다. 오류 발생시 컴포넌트는 그때까지
사용한 모든 리소스를 반환하고, 업로드되어 서버에 저장된 모든 파일을 자동 삭제함으로써 무결성을 보장한다.
컴포넌트와 무관하게 외부 ASP코드에서 오류가 발생했을 경우에는 FileUpload개체의 DeleteAllSavedFiles Method
호출해서 그때까지 업로드되어 서버에 저장된 모든 파일들을 수동으로 삭제할 수 있다.

<%
On Error Resume Next
Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "c:\data"

uploadform.Save
If Err Then
Response.Write "Error occured : <BR>"
Response.Write Err.Description
End If
...
' 외부 오류 발생으로 업로드 작업을 취소하고자 할 경우
uploadform.DeleteAllSavedFiles
...
%>





■ 개체 레퍼런스


* FileUpload 개체


실제로 파일을 업로드하고 서버에 저장하는 기능을 담당하는 컴포넌트의 가장 핵심이 되는 개체이다.


[ Properties ]

DefaultPath
Syntax : object.DefaultPath [= String]
Type : String
Remarks : 임시파일 및 업로드된 파일을 저장할 디폴트 경로값을 지정하는데 사용한다.
기본값은 "C:\"이다.
Sample :
<%
Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "D:\upload"

uploadform.Save
Set uploadform = Nothing

%>


FileLen
Syntax : object.FileLen
Type : Long (ReadOnly)
Remarks : 업로드된 파일의 길이값을 가진다.
Sample :

<%

Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "D:\upload"

filelength = uploadform.FileLen ' the same expression
filelength = uploadform("file1").FileLen ' the same expression
filelength2= uploadform("file2").FileLen
Response.Write filelength & " KB" ' Result: 1024 KB
Set uploadform = Nothing

%>


FileName
Syntax : object.FileName
Type : String (ReadOnly)
Remarks : 업로드된 파일의 이름(경로 제외)값을 가진다.
Sample :

<%

Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "D:\upload" 

filename = uploadform.FileName ' the same expression
filename = uploadform("file1").FileName ' the same expression
filename2= uploadform("file2").FileName
Response.Write filename ' Result: sample.zip
Set uploadform = Nothing

%>


FilePath
Syntax : object.FilePath
Type : String (ReadOnly)
Remarks : 업로드된 파일의 전체 경로값을 가진다.
Sample :

<%

Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "D:\upload"

filepath = uploadform.FilePath ' the same expression
filepath = uploadform("file1").FilePath ' the same expression
filepath2= uploadform("file2").FilePath
Response.Write filepath ' Result: c:\temp\sample.zip
Set uploadform = Nothing

%>


Form
Syntax : object.Form
Type : Object (ReadOnly / Default Property)
Remarks : Submit된 Form의 각 항목정보를 저장하고 있는 FormItems Collection 개체
Sample :

<%

Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "D:\upload"

title = uploadform.Form.Item("title").Value ' the same expression
title = uploadform.Form("title").Value ' the same expression
title = uploadform("title").Value ' the same expression
title = uploadform("title") ' the same expression
Set uploadform = Nothing

%>


MaxFileLen
Syntax : object.MaxFileLen [= Long]
Type : Long
Remarks : 업로드 가능한 최대파일크기를 제한하는데 사용한다. (단위: Byte)
지정된 크기보다 큰 파일을 업로드할 경우 에러가 발생한다.
기본값은 '무제한'이다.
Sample :

<%

Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "D:\upload"

uploadform.MaxFileLen = 5242880
uploadform.Save
Set uploadform = Nothing

%>


MimeType
Syntax : object.MimeType
Type : String (ReadOnly)
Remarks : 업로드된 파일의 Mime Type값을 가진다.
Sample :
<%
Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "D:\upload"

mimetype = uploadform.MimeType ' the same expression
mimetype = uploadform("file1").MimeType ' the same expression
mimetype2= uploadform("file2").MimeType
Response.Write mimetype ' Result: image/pjpeg
Set uploadform = Nothing

%>


UploadTimeout
Syntax : object.UploadTimeout [= Long]
Type : Long
Remarks : 업로드 Timeout값을 지정하는데 사용한다. (단위: 초)
지정된 시간을 초과하면 Timeout에러가 발생한다.
컴포넌트 외부에서 설정한 Server.ScriptTimeout, Session.Timeout값은 무시된다.
기본값은 3600초(60분)이다.
Sample :
<%
Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "D:\upload"

uploadform.UploadTimeout = 1200
uploadform.Save
Set uploadform = Nothing

%>


ImageFormat  ( New in v1.5 )
Syntax : object.ImageFormat
Type : String (ReadOnly)
Remarks : 업로드된 이미지 파일(BMP/GIF/JPG )의 포멧을 리턴한다.  이미지 파일이 아닌 경우는 Null을 리턴한다.
Sample :
<%
Set uploadform = Server.CreateObject("DEXT.FileUpload") 
uploadform.DefaultPath = "D:\upload"

imageformat = uploadform.ImageFormat          'the same expression
imageformat = uploadform("file1").ImageFormat 'the same expression
imageformat2= uploadform("file2").ImageFormat

Response.Write imageformat                    ' Result: JPG (or BMP or GIF)
Set uploadform = Nothing
%>


ImageWidth  ( New in v1.5 )
Syntax : object.ImageWidth
Type : Long (ReadOnly)
Remarks : 업로드된 이미지 파일(BMP/GIF/JPG )의 폭을 리턴한다.  이미지 파일이 아닌 경우는 -1을 리턴한다.
Sample :
<%
Set uploadform = Server.CreateObject("DEXT.FileUpload") 
uploadform.DefaultPath = "D:\upload"

imagewidth = uploadform.ImageWidth          'the same expression
imagewidth = uploadform("file1").ImageWidth 'the same expression
imagewidth2= uploadform("file2").ImageWidth

Response.Write imagewidth                   ' Result: 1024

Set uploadform = Nothing
%>


ImageHeight ( New in v1.5 )
Syntax : object.ImageHeight
Type : Long (ReadOnly)
Remarks : 업로드된 이미지 파일(BMP/GIF/JPG )의 높이를 리턴한다. 이미지 파일이 아닌 경우는 -1을 리턴한다.
Sample :
<%
Set uploadform = Server.CreateObject("DEXT.FileUpload") 
uploadform.DefaultPath = "D:\upload"

imageheight = uploadform.ImageHeight          'the same expression
imageheight = uploadform("file1").ImageHeight 'the same expression
imageheight2= uploadform("file2").ImageHeight

Response.Write imageheight                    ' Result: 768

Set uploadform = Nothing
%>

 


Version  ( New in v1.5 )
Syntax : object.Version
Type : String (ReadOnly)
Remarks : DEXTUpload 컴포넌트의 version정보를 리턴한다.
Sample :
<%
Set uploadform = Server.CreateObject("DEXT.FileUpload") 
uploadform.DefaultPath = "D:\upload"

Response.Write uploadform.Version        ' Result: 1.5.0
Set uploadform = Nothing
%>

 


ExpirationDate  ( New in v1.5 )
Syntax : object.ExpirationDate
Type : String (ReadOnly)
Remarks : DEXTUpload컴포넌트 평가판의 파기일자를 리턴한다. 정식판의 경우 "Unlimited"라는 문자열을 리턴한다.
Sample :
<%
Set uploadform = Server.CreateObject("DEXT.FileUpload") 
uploadform.DefaultPath = "D:\upload"

Response.Write uploadform.ExpirationDate  ' Result: 11/1/2000
Set uploadform = Nothing
%>


UseIE5BugFix  ( New in v1.5 )
Syntax : object.UseIE5BufFix
Type : Boolean (WriteOnly)
Remarks : 인코딩형식을 영어로 지정한 IE5.0에서 다국어 사용시 발생하는 버그에 대한 자동처리 기능의 사용여부를

지정한다. 기본값은 True로 이 기능을 사용하는 것으로 되어있다.
Sample :
<%
Set uploadform = Server.CreateObject("DEXT.FileUpload") 
uploadform.DefaultPath = "D:\upload"

Response.Write uploadform.ExpirationDate  ' Result: 11/1/2000
Set uploadform = Nothing
%>


LastSavedFileName   ( New in v1.5 )
Syntax : object.LastSavedFileName
Type : String (ReadOnly)
Remarks : 업로드되어 서버에 저장된 파일의 이름(경로 제외)값을 가진다. 업로드한 하나의 파일에 대해
Save()를
여러 번 호출하여 각각 서로 다른 이름으로 저장한 경우에는 가장 최근에 저장된 파일의 이름을 가지게 된다.
Sample :

<%

Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "D:\Temp"
OrgFileName = uploadform("file1").FileName

uploadform("file1").SaveAs("D:\Upload1\" & OrgFileName , False)
Response.Write "Original FileName: " & uploadform("file1").FileName & "<BR>"
Response.Write "Uploaded FileName1: " & uploadform("file1").LastSavedFileName & "<BR>"

uploadform("file1").SaveAs("F:\Upload2\" & OrgFileName , False)
Response.Write "Original FileName: " & uploadform("file1").FileName & "<BR>"
Response.Write "Uploaded FileName2: " & uploadform("file1").LastSavedFileName & "<BR>"

Set uploadform = Nothing
%>


LastSavedFilePath   ( New in v1.5 )
Syntax : object.LastSavedFilePath
Type : String (ReadOnly)
Remarks : 업로드되어 서버에 저장된 파일의 전체 경로값을 가진다. 업로드한 하나의 파일에 대해 Save()를
여러 번 호출하여 각각 서로 다른 이름으로 저장한 경우에는 가장 최근에 저장된 파일의 이름을 가지게 된다.
Sample :

<%

Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "D:\Temp"
OrgFileName = uploadform("file1").FileName

uploadform("file1").SaveAs("D:\Upload1\" & OrgFileName , False)
Response.Write "Original FilePath: " & uploadform("file1").FilePath & "<BR>"
Response.Write "Uploaded FilePath1: " & uploadform("file1").LastSavedFilePath & "<BR>"

uploadform("file1").SaveAs("F:\Upload2\" & OrgFileName , False)
Response.Write "Original FilePath: " & uploadform("file1").FilePath & "<BR>"
Response.Write "Uploaded FilePath2: " & uploadform("file1").LastSavedFilePath & "<BR>"

Set uploadform = Nothing

%>


CodePage  ( New in v2.0 )
Syntax : object.CodePage
Type : Long
Remarks : 업로드컴포넌트 내부적으로 데이터를 처리할 때 사용할 CodePage를 지정한다. 외국어나 유니코드 문자셋을
이용하는 웹페이지에서는 반드시 그 페이지에서 사용하는 문자셋에 대응되는 코드페이지값을 업로드컴포넌트의 CodePage
값으로 지정해 주어야 한다. 기본값은 시스템에 설정된 기본 코드페이지값으로 되어있다. 단, ASP코드에서 명시적으로
Session.CodePage값을 지정해 주었을 경우에는 그 값이 기본값으로 되므로 이 경우에는 CodePage 프로퍼티값의 지정
을 생략해도 된다.


Sample :
<%
Session.CodePage = "65001"
%>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<%
Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "C:\Temp"
uploadform.CodePage = 65001
 
...
Set uploadform = Nothing
%>

 



[ Methods ]

DeleteAllSavedFiles
Syntax : [Long = ] object.DeleteAllSavedFiles
Return Value : Long - 삭제된 파일의 수
Arguments :
Remarks : 업로드를 통해 서버에 저장한 모든 파일을 삭제한다. 주로 컴포넌트 외부에서 오류 발생시 업로드
작업을 취소하고 서버에 남아있는 불필요한 파일들을 삭제하고자 할 때 사용한다. (컴포넌트 내부에
서 오류 발생시에는 자동 호출되어짐.)
Sample :
<%
Set uploadform = Server.CreateObject("DEXT.FileUpload")
...
'컴포넌트 외부의 ASP 코드에서 오류가 난 경우
uploadform.DeleteAllSavedFiles
Set uploadform = Nothing

%>


Save
Syntax : [String = ] object.Save( [strPath], [bOverwrite] )
Return Value : String - 실제로 서버에 저장된 파일명
Arguments : strPath As String (Optional) - 업로드된 파일을 저장할 경로. 생략할 경우 DefaultPath Property
가 가리키는 경로로 저장된다.
bOverwrite As Boolean (Optional) - 같은 이름의 파일이 이미 존재할 경우 Overwrite유무를 지
정한다. 기본값은 True이고, False로 지정할 경우 filename(2).ext, filename(3).ext 등과 같이
유일한 파일명을 구해서 저장하게 된다.
Remarks : 업로드된 파일을 원래 파일명과 동일한 이름으로 디폴트 경로 또는 지정한 경로에 저장한다.
Sample :
<%
Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "d:\temp"
uploadform.Save ' the same expression
uploadform("file1").Save ' the same expression
uploadform("file2").Save
Set uploadform = Nothing

%>


SaveVirtual
Syntax : [String = ] object.SaveVirtual( strVirtualPath, [bOverwrite] )
Return Value : String - 실제로 서버에 저장된 파일명
Arguments : strVirtualPath As String - 업로드된 파일을 저장할 가상경로.
bOverwrite As Boolean (Optional) - 같은 이름의 파일이 이미 존재할 경우 Overwrite유무를 지
정한다. 기본값은 True이고, False로 지정할 경우 filename(2).ext, filename(3).ext 등과 같이
유일한 파일명을 구해서 저장하게 된다.
Remarks : 업로드된 파일을 원래 파일명과 동일한 이름으로 지정한 가상경로에 저장한다.
Sample :
<%
Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "d:\temp"
uploadform.SaveVirtual "/virtualloc/" ' the same expression
uploadform("file1").SaveVirtual "/virtualloc/" ' the same expression
uploadform("file2").SaveVirtual "/virtualloc/"
Set uploadform = Nothing

%>


SaveAs
Syntax : [String = ] object.SaveAs( strNewFilename, [bOverwrite] )
Return Value : String - 실제로 서버에 저장된 파일명
Arguments : strNewFilename As String - 업로드 후 새 이름으로 저장할 파일명(Full Path)
bOverwrite As Boolean (Optional) - 같은 이름의 파일이 이미 존재할 경우 Overwrite유무를 지
정한다. 기본값은 True이고, False로 지정할 경우 filename(2).ext, filename(3).ext 등과 같이
유일한 파일명을 구해서 저장하게 된다.
Remarks : 업로드된 파일을 새 이름으로 지정한 경로에 저장한다.
Sample :
<%
Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "d:\temp"
uploadform.SaveAs "d:\upload\newfile.zip" ' the same expression
uploadform("file1").SaveAs "d:\upload\newfile.zip" ' the same expression
uploadform("file2").SaveAs "d:\upload\newfile2.zip"
Set uploadform = Nothing

%>


SaveAsVirtual
Syntax : [String = ] object.SaveAsVirtual( strNewFilename, [bOverwrite] )
Return Value : String - 실제로 서버에 저장된 파일명
Arguments : strNewFilename As String - 업로드된 파일을 저장할 가상경로 파일명
bOverwrite As Boolean (Optional) - 같은 이름의 파일이 이미 존재할 경우 Overwrite유무를 지
정한다. 기본값은 True이고, False로 지정할 경우 filename(2).ext, filename(3).ext 등과 같이
유일한 파일명을 구해서 저장하게 된다.
Remarks : 업로드된 파일을 새 이름으로 지정한 가상경로에 저장한다.
Sample :

<%

Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "d:\temp"
uploadform.SaveAsVirtual "/virtualloc/newfile.zip" ' the same expression
uploadform("file1").SaveAsVirtual "/virtualloc/newfile.zip" ' the same expression
uploadform("file2").SaveAsVirtual "/virtualloc/newfile.zip"
Set uploadform = Nothing

%>


SaveAsBlob
Syntax : object.SaveAsBlob( dbField )
Return Value :
Arguments : dbField As ADODB.Field - 업로드된 파일을 저장할 Database의 BLOB필드
Remarks : 업로드된 파일을 Database의 BLOB필드에 저장한다.
Sample :
<%
...
Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "d:\temp"

Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strQuery, cn, 3,3
rs.AddNew
uploadform.SaveAsBlob rs("filedata") ' the same expression
uploadform("file1").SaveAsBlob rs("filedata") ' the same expression
uploadform("file2").SaveAsBlob rs("filedata2")
rs.Update
Set uploadform = Nothing

%>


FileExists  ( New in v1.5 )
Syntax : [Boolean = ] object.FileExists( strFilename )
Return Value : Boolean - 파일이 존재하면 True, 존재하지 않으면 False를 리턴한다.
Arguments : strFilename As String - 존재여부를 체크할 파일의 전체경로 (물리적경로만 가능)
Remarks : 특정파일의 존재여부를 체크한다.
Sample :

<%

Set uploadform = Server.CreateObject("DEXT.FileUpload")
If uploadform.FileExists("c:\temp\sample.zip") Then
   Response.Write "File exists : Sample.zip<br>"
Else
   Response.Write "File not exists : Sample.zip<br>"
End If
Set uploadform = Nothing
%>


DeleteFile  ( New in v1.5 )
Syntax : [Boolean = ] object.DeleteFile( strFilename )
Return Value : Boolean - 정상적으로 파일을 삭제했으면 True, 파일 부재로 삭제하지 못했으면 False를 리턴한다.
Arguments : strFilename As String - 삭제할 파일의 전체경로 (물리적경로만 가능)
Remarks : 서버에 업로드된 파일 또는 서버에 존재하는 파일을 삭제한다.
Sample :

<%

Set uploadform = Server.CreateObject("DEXT.FileUpload")
UploadedFile1 = uploadform("file1").Save 
UploadedFile2 = uploadform("file2").Save
...
'If you want to delete the first file
uploadform.DeleteFile UploadedFile1
...
Set uploadform = Nothing
%>


Flush  ( New in v2.0 )
Syntax :  object.Flush()
Return Value : 없음.
Arguments : 없음.
Remarks : 서버에 어떠한 파일(임시파일 포함)도 저장하지 않으면서 웹브우저가 보내오는 모든 데이터를 무시하고 흘려버린다.
Sample :

<%
Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "D:\Temp"

If Request.TotalBytes > 1048576 Then 
     
uploadform.Flush
      Response.Write "Warning: File size must be less than 1 MBytes."
Else
      uploadform.Save
      Response.Write "File-upload completed."
End If

Set uploadform = Nothing
%>




* FileDownload 개체

서버에 있는 파일 또는 데이터베이스 BLOB필드에 있는 이진데이터를 웹브라우저를 통해 클라이언트 사용자의 하드디스크 파일로 다운로드할 수 있는 기능을 가진 개체이다.

[ Methods ]

Download
Syntax : object.Download( strFilename )
Return Value :
Arguments : strFilename As String - 다운로드할 파일명(전체경로)
Remarks : 서버에 있는 파일을 웹브라우저를 통해 클라이언트 사용자에게로 다운로드한다.
Sample :

<%

Set objDown = Server.CreateObject("DEXT.FileDownload")
objDown.Download "c:\data\filedata.zip"
Set objDown = Nothing

%>


DownloadVirtual
Syntax : object.DownloadVirtual( strFilename )
Return Value :
Arguments : strFilename As String - 다운로드할 가상경로 파일명
Remarks : 서버의 가상경로에 있는 파일을 웹브라우저를 통해 클라이언트 사용자에게로 다운로드한다.
Sample :

<%

Set objDown = Server.CreateObject("DEXT.FileDownload")
objDown.DownloadVirtual "/virtualloc/filedata.zip"
Set objDown = Nothing

%>


DownloadBlob
Syntax : object.DownloadBlob( dbField )
Return Value :
Arguments : dbField As ADODB.Field - 다운로드할 Database BLOB필드
Remarks : Database에 있는 BLOB 데이터를 웹브라우저를 통해 클라이언트 사용자에게로 다운로드한다.
Sample :

<%

Set objDown = Server.CreateObject("DEXT.FileDownload")
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strQuery, cn, 3, 1
objDown.DownloadBlob rs("filedata")
Set objDown = Nothing

%>



* FormItem 개체

Submit된 Form의 각 Input항목 정보를 가지는 개체로, FileUpload 개체의 Form property가 가리키는 FormItems Collection의 개별 항목으로써 이용된다.

[ Properties ]

FileLen
Syntax : object.FileLen
Type : Long (ReadOnly)
Remarks : Input항목이 "file"인 경우 업로드된 파일의 길이값을 가진다.
Sample : FileUpload 개체의 FileLen property 참조


FileName
Syntax : object.FileName
Type : String (ReadOnly)
Remarks : Input항목이 "file"인 경우 업로드된 파일의 이름(경로 제외)값을 가진다.
Sample : FileUpload 개체의 FileName property 참조


FilePath
Syntax : object.FilePath
Type : String (ReadOnly)
Remarks : Input항목이 "file"인 경우 업로드된 파일의 전체 경로값을 가진다.
Sample :FileUpload 개체의 FilePath property 참조


MimeType
Syntax : object.MimeType
Type : String (ReadOnly)
Remarks : 업로드된 파일의 Mime Type값을 가진다.
Sample : FileUpload 개체의 MimeType property 참조


Name

Syntax : object.Name
Type : String (ReadOnly)
Remarks : Input항목에 대한 Name를 가진다.
Sample :

<%

Set uploadform = Server.CreateObject("DEXT.FileUpload")
For Each item In uploadform.Form
   strName = item.Name
   strValue = item.Value
Response.Write strName & " = " & strValue & "<BR>"
Next
%>


Value
Syntax : object.Value
Type : String (ReadOnly / Default Property)
Remarks : Input항목에 대한 Value를 가진다. (file인 경우는 전체 경로값(FilePath Property와 동일)을 가진다.)
Sample :

<%

Set uploadform = Server.CreateObject("DEXT.FileUpload")
title = uploadform.Form.Item("title").Value ' the same expression
title = uploadform.Form("title").Value ' the same expression
title = uploadform("title").Value ' the same expression
title = uploadform("title") ' the same expression
Set uploadform = Nothing

%>

ImageFormat  ( New in v1.5 )
Syntax : object.ImageFormat
Type : String (ReadOnly)
Remarks : 업로드된 이미지 파일(BMP/GIF/JPG )의 포멧을 리턴한다.  이미지 파일이 아닌 경우는 Null을 리턴한다.
Sample : FileUpload 개체의 ImageFormat  property 참조


ImageWidth  ( New in v1.5 )
Syntax : object.ImageWidth
Type : Long (ReadOnly)
Remarks : 업로드된 이미지 파일(BMP/GIF/JPG )의 폭을 리턴한다.  이미지 파일이 아닌 경우는 -1을 리턴한다.
Sample :  FileUpload 개체의 ImageWidth  property 참조


ImageHeight  ( New in v1.5 )
Syntax : object.ImageHeight
Type : Long (ReadOnly)
Remarks : 업로드된 이미지 파일(BMP/GIF/JPG )의 높이를 리턴한다. 이미지 파일이 아닌 경우는 -1을 리턴한다.
Sample : FileUpload 개체의 ImageHeight  property 참조


LastSavedFileName   ( New in v1.5 )
Syntax : object.LastSavedFileName
Type : String (ReadOnly)
Remarks : Input항목이 "file"인 경우 업로드되어 서버에 저장된 파일의 이름(경로 제외)값을 가진다.
Sample : FileUpload 개체의 LastSavedFileName property 참조


LastSavedFilePath   ( New in v1.5 )
Syntax : object.LastSavedFilePath
Type : String (ReadOnly)
Remarks : Input항목이 "file"인 경우 업로드되어 서버에 저장된 파일의 전체 경로값을 가진다.
Sample :
FileUpload 개체의 LastSavedFilePath property 참조



[ Methods ]

IsFileItem
Syntax : [Boolean = ] object.IsFileItem( )
Return Value : Boolean - Input항목이 "file"이면 True, 그 외는 False
Arguments :
Remarks : Input항목이 "file"인지 여부를 체크한다.
Sample :
<%
' Type이 "file"인 모든 Input항목을 저장하는 예제
Set uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = "C:\Upload"
For Each item In uploadform.Form
If item.IsFileItem Then item.Save
Next
Set uploadform = Nothing
%>

Save
Syntax : [String = ] object.Save( [strPath], [bOverwrite] )
Return Value : String - 실제로 서버에 저장된 파일명
Arguments : strPath As String (Optional) - 업로드된 파일을 저장할 경로. 생략할 경우 DefaultPath Property
가 가리키는 경로로 저장된다.
bOverwrite As Boolean (Optional) - 같은 이름의 파일이 이미 존재할 경우 Overwrite유무를 지
정한다. 기본값은 True이고, False로 지정할 경우 filename(2).ext, filename(3).ext 등과 같이
유일한 파일명을 구해서 저장하게 된다.
Remarks : Input항목이 "file"인 경우 업로드된 파일을 원래 파일명과 동일한 이름으로 디폴트 경로 또는 지정
한 경로에 저장한다.
Sample : FileUpload 개체의 Save method 참조


SaveVirtual
Syntax : [String = ] object.SaveVirtual( strVirtualPath, [bOverwrite] )
Return Value : String - 실제로 서버에 저장된 파일명
Arguments : strVirtualPath As String - 업로드된 파일을 저장할 가상경로.
bOverwrite As Boolean (Optional) - 같은 이름의 파일이 이미 존재할 경우 Overwrite유무를 지
정한다. 기본값은 True이고, False로 지정할 경우 filename(2).ext, filename(3).ext 등과 같이
유일한 파일명을 구해서 저장하게 된다.
Remarks : Input항목이 "file"인 경우 업로드된 파일을 원래 파일명과 동일한 이름으로 지정한 가상경로에 저
장한다.
Sample : FileUpload 개체의 SaveVirtual method 참조


SaveAs
Syntax : [String = ] object.SaveAs( strNewFilename, [bOverwrite] )
Return Value : String - 실제로 서버에 저장된 파일명
Arguments : strNewFilename As String - 업로드후 새 이름으로 저장할 파일명(Full Path)
bOverwrite As Boolean (Optional) - 같은 이름의 파일이 이미 존재할 경우 Overwrite유무를 지
정한다. 기본값은 True이고, False로 지정할 경우 filename(2).ext, filename(3).ext 등과 같이
유일한 파일명을 구해서 저장하게 된다.
Remarks : Input항목이 "file"인 경우 업로드된 파일을 새 이름으로 지정한 경로에 저장한다.
Sample : FileUpload 개체의 SaveAs method 참조


SaveAsVirtual
Syntax : [String = ] object.SaveAsVirtual( strNewFilename, [bOverwrite] )
Return Value : String - 실제로 서버에 저장된 파일명
Arguments : strNewFilename As String - 업로드된 파일을 저장할 가상경로 파일명
bOverwrite As Boolean (Optional) - 같은 이름의 파일이 이미 존재할 경우 Overwrite유무를 지
정한다. 기본값은 True이고, False로 지정할 경우 filename(2).ext, filename(3).ext 등과 같이
유일한 파일명을 구해서 저장하게 된다.
Remarks : Input항목이 "file"인 경우 업로드된 파일을 새 이름으로 지정한 가상경로에 저장한다.
Sample : FileUpload 개체의 SaveAsVirtual method 참조


SaveAsBlob
Syntax : object.SaveAsBlob( dbField )
Return Value :
Arguments : dbField As ADODB.Field - 업로드된 파일을 저장할 Database의 BLOB필드
Remarks : Input항목이 "file"인 경우 업로드된 파일을 Database의 BLOB필드에 저장한다.
Sample : FileUpload 개체의 SaveAsBlob method 참조




* FileUploadMonitor 개체

업로드 진행상황을 모니터링하는 Server-side Graphical Progress Indicator 기능을 가진 개체이다.

[ Methods ]

UseMonitor
Syntax : object.UseMonitor( bUse )
Return Value :
Arguments : bUse As Boolean - True: 업로드 진행상황 모니터링기능 사용 / False: 사용하지 않음
Remarks : 업로드 진행상황 모니터링기능의 사용여부를 지정한다. 모니터링기능을 사용하고자 할
경우는 반드시 Submit할 Form을 작성하는 페이지 내에서 UseMonitor(True)를 호출해야
한다. UseMonitor Method를 호출하지 않거나, UseMonitor(False)를 호출할 경우는 모니
터링기능을 사용하지 않는 것으로 간주된다.
Sample :

<%

Set objMon = Server.CreateObject("DEXT.FileUploadMonitor")
objMon.UseMonitor(True)
Set objMon = Nothing
%>


ShowMonitor
Syntax : object.ShowMonitor
Return Value :
Arguments :
Remarks : 업로드 진행상황을 Progress Bar로 보여주고, 전체 파일용량, 남은 파일용량, 업로드 속도,
남은 시간 등의 정보를 실시간으로 보여준다.
Sample :
<%
Set objMon = Server.CreateObject("DEXT.FileUploadMonitor")
objMon.ShowMonitor
Set objMon = Nothing
%>




* BlobManager 개체

Database에서 BLOB 데이터를 처리하기 위한 개체로, BLOB필드에 파일을 저장하거나 BLOB데이터를 파일로 저장하는 등의 기능을 가지고 있다.

[ Methods ]

SaveFileAsBlob
Syntax : object.SaveFileAsBlob( strFilename, dbField )
Return Value :
Arguments : strFilename As String - BLOB필드에 저장할 파일의 이름(전체경로)
dbField As ADODB.Field - 파일을 저장할 BLOB필드
Remarks : 서버에 존재하는 파일을 Database BLOB필드로 저장한다.
Sample :
<%
Set objBlobMan = Server.CreateObject("DEXT.BLOBManager")
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strQuery, cn, 3,3
rs.AddNew
objBlobMan.SaveFileAsBlob "c:\file.zip", rs("filedata")
rs.Update
Set objBlobMan = Nothing

%>


SaveBlobAsFile
Syntax : [String =] object.SaveBlobAsFile( dbField, strFilename, [bOverwrite] )
Return Value : String - 실제로 저장된 파일명
Arguments : dbField As ADODB.Field - 파일로 저장할 BLOB필드
strFilename As String - BLOB데이터를 저장할 파일명(전체경로)
bOverwrite As Boolean (Optional) - 같은 이름의 파일이 이미 존재할 경우 Overwrite유무를 지
정한다. 기본값은 True이고, False로 지정할 경우 filename(2).ext, filename(3).ext 등과 같이
유일한 파일명을 구해서 저장하게 된다.

Remarks : Database에 있는 BLOB데이터를 서버의 디스크 파일로 저장한다.
Sample :
<%
Set objBlobMan = Server.CreateObject("DEXT.BLOBManager")
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strQuery, cn, 3,1
objBlobMan.SaveBlobAsFile rs("filedata"), "c:\file.zip"
Set objBlobMan = Nothing

%>




■ DEXTUpload 예제

- Sample 설치방법

설치프로그램을 이용하여 DEXTUpload 컴포넌트를 설치한 후, Sample을 테스트해 보고자 할 경우에는 다음과 같은 추가적인 작업이 필요하다.
1) IIS Web root 하위에 "DEXTUploadSamples"라는 이름의 가상 디렉토리를 만든다.
2) 생성한 가상 디렉토리를 DEXTUpload와 함께 설치된 "Samples" 폴더에 연결한다.
3) "Samples"의 하위 폴더인 "DATA" 폴더에 쓰기 권한을 부여한다. "DATA" 폴더는 가상경로로의 업로드 예제에서 업로드된 파일이 저장되는 곳이다.
4) ODBC 데이터 원본 관리자에서 "DEXTUPLOAD"라는 이름의 DSN을 추가하고 "Samples" 폴더에 있는 dextupload.mdb 파일을 지정한다. dextupload.mdb는 데이터베이스 관련 예제 수행을 위해 필요하다.


- Sample List

Sample Name

Sample Description

[ UPLOAD Samples ]
1. Simple Upload (without Progress Indicator) 한 개의 파일을 업로드하는 예제(Progress indicator없음)
2. Simple Upload 한 개의 파일을 업로드하는 예제
3. Multiple Upload 여러 개의 파일을 업로드 하는 예제
4. Uploading with other Form Elements 다른 폼 요소들과 함께 업로드 하는 예제
5. Uploading using only One Page 하나의 ASP 페이지를 이용한 업로드 예제
6. Uploading as Other Name 업로드한 파일을 새 이름으로 저장하는 예제
7. Uploading to Virtual Path 가상경로에 업로드 하는 예제
8. Uploading to Virtual Directory as Other Name 가상경로에 업로드 후 새 이름으로 저장하는 예제
9. Getting Image Size of Uploaded Image Files ( New in v1.5 ) 업로드된 이미지 파일의 이미지 폭과 높이를 구하는 예제
10. Saving As Unique File Name 업로드한 파일을 유일한 파일이름으로 저장하는 예제
11. Saving As User-defined Unique File Name ( New in v1.5 ) 업로드한 파일을 사용자정의의 유일한 파일이름으로 저장하는 예제
12. Limiting the Upload Size 업로드 가능한 파일의 크기를 제한하는 예제
13. Setting the Upload Timeout 업로드 Timeout을 설정하는 예제
14. Restricting File Types 업로드 가능한 파일의 종류를 제한하는 예제
15. Uploading to Database BLOB 데이터베이스 BLOB 필드에 업로드 하는 예제
16. Deleting All Saved Files when error occurred 오류 발생 시 업로드된 파일들을 모두 삭제하는 예제
17. Progress Indicator With Banner 배너가 포함된 Progress Indicator 예제
18. Using to Visual Basic WebClass ( Added in v1.5 ) Visual Basic IIS Application(WebClass)에서의 사용 예제
[ DOWNLOAD Samples ]
19. Downloading Files 파일 다운로드 예제
20. Downloading Files From Virtual Path 가상경로에서의 파일 다운로드 예제
21. Downloading from Database BLOB 데이터베이스 BLOB을 다운로드 하는 예제
[ Blob Handling in server ]
22. Saving a File in server as Database BLOB 서버 내 파일을 데이터베이스 BLOB 필드에 저장하는 예제
23. Saving Database BLOB as File in server 데이터베이스 BLOB을 서버 내 파일로 저장하는 예제.

 

 

- Sample Path

Sample Name

Sample Path

[ UPLOAD Samples ]
1. Simple Upload (without Progress Indicator) \Samples\SimpleUploadNoProgress
2. Simple Upload \Samples\SimpleUpload
3. Multiple Upload \Samples\Multileupload
4. Uploading with other Form Elements \Samples\UploadWithElements
5. Uploading using only One Page \Samples\OnepageUpload
6. Uploading as Other Name \Samples\SaveAs
7. Uploading to Virtual Path \Samples\SaveVirtual
8. Uploading to Virtual Path as Other Name \Samples\SaveAsVirtual
9. Getting Image Size of Uploaded Image Files \Samples\GetImageSize
10. Saving As Unique File Name \Samples\SaveAsUnique
11. Saving As User-defined Unique File Name \Samples\SaveAsUserUnique
12. Limiting the Upload Size \Samples\LimitSize
13. Setting the Upload Timeout \Samples\LimitTimeout
14. Restricting File Types \Samples\RestrictFileTypes
15. Uploading to Database BLOB \Samples\SaveAsBlob
16. Deleting All Saved Files when error occurred \Samples\DeleteAllSavedFiles
17. Progress Indicator With Banner \Samples\ProgressWithBanner
18. Using to Visual Basic WebClass \Samples\VBWebClass
[ DOWNLOAD Samples ]
19. Downloading Files \Samples\Download
20. Downloading Files From Virtual Path \Samples\DownloadVirtual
21. Downloading from Database BLOB \Samples\DownloadBlob
[ Blob Handling in server ]
22. Saving Files in server as Database BLOB \Samples\FileToBlob
23. Saving Database BLOB as Files in server \Samples\BlobToFile

 

 

 

■ 자주 묻는 질문들

Q1. DEXTUpload를 사용할 수 있는 시스템 환경은?

    Windows NT 4.0 / Windows 2000 이상의 시스템에서만 가능하며, Windows NT 4.0의 경우는 IIS 4.0, Service Pack 5 이상이 설치되어 있어야 한다.
    따라서, Windows98 Personal Web Server나 Windows NT IIS 3.0 이하에서는 작동하지 않는다.


Q2. RFC 1867이란 무엇이며, 이에 대한 정보를 얻을 수 있는 곳은?

    RFC 1867은 HTML의 Form을 확장해서 웹브라우저로부터 서버로의 Form기반의 파일 업로드를 수행하게 하는 인터넷 표준이다.
    이에 대한 상세한 정보는 http://www.cis.ohio-state.edu/htbin/rfc/rfc1867.html에서 얻을 수 있다.


Q3. 무료로 제공되는 Microsoft Posting Acceptor(PA)와 DEXTUpload를 비교한다면?

    DEXTUpload는 ASP와의 완전한 통합이라는 특징을 갖기 때문에 PA와는 달리 다음과 같은 여러 가지 장점을 가진다.
    익명 연결 : PA는 ISAPI DLL을 이용하기 때문에 ASP 애플리케이션과는 별도로 추가적인 보안특성을 고려해야 한다. 반면에, DEXTUpload는 ASP 애플리케이션 차원에서 유연성 있는 보안 메커니즘을 적용할 수 있다.

    업로드 제어 : PA는 업로드 도중 업로드와 관련된 어떠한 부가적인 제어도 허용하지 않는다. 반면에, DEXTUpload는 업로드 가능한 파일용량 제한, 업로드 Timeout설정, 업로드 파일종류 제한, 업로드되는 위치의 변경, 등의 작업들을 동적으로 수행할 수 있다.

    데이터베이스로의 업로드 : PA는 파일로만 업로드 할 수 있다. 반면에, DEXTUpload는 ADO와의 통합으로 파일뿐만 아니라 데이터베이스 BLOB필드로의 파일 업로드 및 다운로드가 가능하다.

    표준 지원 : PA는 독자적인 WebPost API를 이용한 반면, DEXTUpload는 인터넷 표준인 RFC 1867을 따르고 있기 때문 에 웹브라우저에 관계없이 동일한 형태의 폼을 작성할 수 있다.


Q4. FTP기반의 파일 업로드 메커니즘과 DEXTUpload를 비교한다면?

    DEXTUpload는 ASP와의 완전한 통합이라는 특징을 갖기 때문에 FTP와는 달리 사용의 용이성, 유연성을 비롯해 서 다양한 장점들을 제공한다.
    보안 및 인증 : FTP는 다수의 사용자 계정을 관리하거나 익명 연결을 허용하는 등 별도의 관리작업이 필요할 뿐만 아니라, 보안을 이유로 외부접근을 금지시키는 경우가 많다.
    반면에, DEXTUpload는 웹을 통해 실행되 기 때문에 별도의 계정관리 부담이 없고, 방화벽, 프락시 서버 등과도 문제없이 작동하며, SSL을 이용 하여 암호화된 파일 업로드 및 다운로드 기능을 구현하는 것이 가능하다.

    업로드 제어 : DEXTUpload는 업로드 가능한 파일 용량 제한, 업로드 Timeout설정, 업로드 파일종류 제한, 업로드 되는 위치의 변경 등과 관련된 다양한 제어를 동적으로 수행할 수 있어 FTP와는 달리 업로드 제어에 대한 유연성이 뛰어나다. 데이터베이스로의 업로드 : FTP는 파일로만 업로드 및 다운로드 할 수 있다. 반면에, DEXTUpload는 파일 뿐만 아니라 데이베이스 BLOB필드로의 파일 업로드 및 다운로드가 가능하다.


Q5. CGI기반의 파일 업로드 메커니즘과 DEXTUpload를 비교한다면?

    DEXTUpload는 ASP와의 완전한 통합이라는 특징을 갖기 때문에 CGI와는 달리 여러 가지 장점을 가진다.
    CGI와는 달리 DEXTUpload는 in-process DLL이기 때문에 파일 크기와 관계없이 CGI보다 빠른 업로드 속도를 가질 뿐만 아니라,
    다수 동시 업로드의 경우에도 안정성이 뛰어나다. 그 외에도 익명연결, 업로드 제어, 데이터베이스 로의 업로드 등 CGI기반에서는 구현하기 어려운 여러 가지 특징들을 제공한다.


Q6. 다른 파일 업로드 컴포넌트 제품들과 비교해서 DEXTUpload가 가지는 두드러진 특징은?

    DEXTUpload는 기본적으로 대용량 파일의 다수 동시 업로드를 무리 없이 수행할 수 있도록 빠른 업로드 속도와 낮은 리소스 점유율을 지닌다는 특징을 가지고 있다. 이와 함께, 현재의 업로드 진행상태를 사용자가 시각적으로 인지할 수 있도록 서버측 업로드 진행율 표시기를 제공한다. 그 밖에도 높은 퍼포먼스와 유용성을 갖춘 다양한 기능들을 제공하고 있다.


Q7. 일반적으로 용량이 큰 파일을 업로드할 경우 Server.ScriptTimeout(default: 90sec), Session.Timeout(default: 20min)에 의해 Timeout에러가 발생할 수 있다. DEXTUpload의 경우도 이러한 Timeout에러를 막기 위해 별도로 업로드 작업 전에 Server.ScriptTimeout, Session.Timeout 값의 설정이 필요한가?

    필요 없다. DEXTUpload는 자체적으로 "UploadTimeout"이라는 Property를 제공하며 기본 값은 60분으로 설정되어 있다. 이 값은 필요에 따라 언제든지 변경이 가능하며 Server.ScriptTimeout이나 Session.Timeout 값의 영향을 받지 않으면서 긴 시간이 소요되는 작업을 정상적으로 수행할 수 있게 한다.


Q8. DEXTUpload와 SSL(Secure Sockets Layer)을 이용해서 암호화된 파일의 전송이 가능한가?

    가능하다. DEXTUpload는 IIS와 동일한 보안문맥(Security Context)에서 실행되므로 IIS의 보안특성을 그대로 상속받는다. 따라서 SSL을 이용하도록 구성된 웹서버라면, DEXTUpload를 이용해서 암호화된 파일의 업로드와 다운로드를 수행할 수 있다.


Q9. 파일 다운로드시 <a href="http://yourhost/file.ext> 또는 <a href="ftp://yourhost/file.ext >과 같은 방법을 쓰면 되므로, DEXTUpload.Download를 써야할 이유가 있는가
?

    URL을 지정하는 방법은 다운로드할 파일들이 가상 디렉토리에 존재해야 한다는 것을 의미한다. 또한, 파일 종류에 따라 웹브라우저가 나름대로의 행위를 하기 때문에, 모든 파일에 대해 항상 다운로드 대화상자가 나타나게 할 수도 없다. 그러나, DEXTUpload의 다운로드기능을 이용하면 가상 디렉토리 뿐만아니라 일반 디렉토리에 존재하는 파일도 다운로드할 수 있으며, 모든 파일에 대해 항상 다운로드 대화상자를 나타나게 할 수도 있다.


Q10. "Server object error, ASP 0177 (0x800401F3). Server.CreateObject Failed" 라는 오류의 의미는?

    DEXTUpload가 Windows Registry에 등록되어 있지 않을 경우 발생하는 오류 메시지이다. 설치프로그램을 이용해서 DEXTUpload 컴포넌트를 재설치하면 된다. 구체적인 방법은 "설치안내" 부분을 참고하면 된다.

DEXTUpload 지원

(주)DEXT 홈페이지 (www.dext.com)

DEXTUpload 사이트 (www.dextupload.com )


관련글 더보기