나누미넷 도움말 센터

Home > ASP 다운로드 예제

ASP 다운로드 예제

<%

Response.Buffer = False

filename = replace(request.form("filename"),"'","''")       '첨부파일
filedir = Server.MapPath("/upload/")                            ' 업로드할 폴더 경로
                                
filepath = filedir &"\"& filename
filename = filename
file_types = lcase(right(filename,3))
                                
if file_types = "jpg" or file_types = "gif" or file_types = "bmp" or file_types = "txt" or file_types = "html" or file_types = "html" then
        Response.AddHeader "Content-Disposition","attachment;filename=" & filename
else
        Response.AddHeader "Content-Disposition","inline;filename=" & filename
end if



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"
                                

Dim objStream,buff
Set objstream=server.createobject("adodb.stream")
     objStream.open
     objStream.LoadFromFile(filepath)
     buff=objStream.readtext(-1)
     Response.BinaryWrite buff
Set objStream = Nothing


%>