다운로드할 파일경로
<a href="download.asp?filename=
파일이름.확장자">
파일이름</a>
예시 ↓
<a href="/bbs/download.asp?filename=<%=rs4("bf_file")%>"><%=rs4("bf_file")%></a>
***************** download.asp 파일생성 *********************************
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<% Response.CharSet = "utf-8" %>
<%
Response.Buffer = False
Response.Expires = -1440
Dim file, path, filepath,fileext,imgsrc
Dim uploadYn
file = request("filename")
path = "/upload/" '상수값 get value
filepath = Server.Mappath("/") & "\" & path & "\" & file
Response.CacheControl = "public"
Response.ContentType = "application/unknown"
'Response.AddHeader "Content-Disposition","attachment;filename=" & file '다운받을때 파일 이름보이는 곳
Response.AddHeader "Content-Disposition","attachment;filename=" & Server.URLPathEncode(file) & ""
Response.AddHeader "Content-Transfer-Encoding", "binary"
Response.AddHeader "Pragma", "no-cache"
Response.AddHeader "Expires", "0" ' 이부분은 넣어서 될때 있고 안될때 있음; 쫌 찾아봐야댐...;;
If InStrRev(file, ".") <> 0 Then
fileext = Mid(file, InStrRev(file, ".")) '파일확장자를 가져옴
Else
fileext = ""
End If
'파일유효성 체크
'*************************************************************************
uploadYn = False
Select Case LCase(fileext)
'이미지관련
Case ".gif",".jpg",".jpeg",".bmp"
uploadYn = True
'문서관련
Case ".pdf",".xls",".ppt",".doc",".hwp",".txt",".doc",".docx",".mpp"
uploadYn = True
'압축관련
Case ".zip",".alz",".rar"
uploadYn = True
'동영상관련
Case ".avi",".mpg",".asf","wma",".flv"
uploadYn = True
'기타
Case ".swf",".dwg"
uploadYn = True
Case Else
uploadYn = False
End Select
If InStrRev(file, "../") <> 0 Then
uploadYn = False
End if
If( uploadYn = False ) Then
response.write "<script>"
response.write "alert('This is not download');"
response.Write "history.back();"
response.write "</script>"
Response.End
End If
'--------------------------------------------------------------------
Dim objStream
Dim download
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.OPen
objStream.Type = 1
objStream.LoadFromFile filepath
download = objstream.Read
Response.BinaryWrite download
Set objStream = nothing
%>