<%
response.buffer = true
dim strfilepath, strfilesize, strfilename
const adtypebinary = 1
strfilepath = request.querystring("file")
strfilesize = request.querystring("size")
strfilename = request.querystring("name")
response.clear
8*******************************8
requires mdac 2.5 to be stable
i recommend mdac 2.6 or 2.7
8*******************************8
set objstream = server.createobject("adodb.stream")
objstream.open
objstream.type = adtypebinary
objstream.loadfromfile strfilepath
strfiletype = lcase(right(strfilename, 4))
feel free to add your own content-types here
select case strfiletype
case ".asf"
contenttype = "video/x-ms-asf"
case ".avi"
contenttype = "video/avi"
case ".doc"
contenttype = "application/msword"
case ".zip"
contenttype = "application/zip"
case ".xls"
contenttype = "application/vnd.ms-excel"
case ".gif"
contenttype = "image/gif"
case ".jpg", "jpeg"
contenttype = "image/jpeg"
case ".wav"
contenttype = "audio/wav"
case ".mp3"
contenttype = "audio/mpeg3"
case ".mpg", "mpeg"
contenttype = "video/mpeg"
case ".rtf"
contenttype = "application/rtf"
case ".htm", "html"
contenttype = "text/html"
case ".asp"
contenttype = "text/asp"
case else
handle all other files
contenttype = "application/octet-stream"
end select
response.addheader "content-disposition", "attachment; filename=000" & strfilename
response.addheader "content-length", strfilesize
in a perfect world, your client would also have utf-8 as the default
in their browser
response.charset = "utf-8"
response.contenttype = contenttype
response.binarywrite objstream.read
response.flush
objstream.close
set objstream = nothing
%>
