본문 바로가기

Development/ASP

ASP File Download


화면 디자인

 

  <TR>
   <TD width=100 align=center bgcolor="#f0f0f0">첨부파일</TD>
   <TD>&nbsp;<a href="download.asp?filename=<%=attachfile%>"><%=attachfile%></a></TD>
  </TR>


 

다운로드 처리 ASP 코드 (download.asp)

 

<%
 filename = request("filename")
 filedir=Server.MapPath("\") & "/UPLOAD/"

 response.addheader "Content-Type","Charset=EUC-KR"
 response.contenttype = "application/unkown"                            ' 알수없는 프로그램 타입(종류)으로 설정
 response.addheader "content-disposition", "attachment;filename="&filename

 Set obj = Server.CreateObject("ADODB.Stream")
 obj.open
 obj.type = 1
 obj.loadfromfile filedir & filename
 download = obj.read
 response.binarywrite download
 Set obj=nothing
%>

 

화면에 "파일 다운로드" 윈도우 팝업이 뜨면서 "실행,저장,취소"를 선택할수 있고 실행 완료되면 원래 화면상태로 돌아간다.

 

[출처] ASP File Download|작성자 포스맨

'Development > ASP' 카테고리의 다른 글

ASP에서 Class 사용  (0) 2009.06.13
5가지 주요 객체  (0) 2009.06.13
ASP로 데이터베이스 처리 (ADO)  (0) 2009.06.13
페이지 로딩시간 초로 확인하는 방법  (0) 2009.06.13
ServerVariables  (0) 2009.06.13