| The following is the code fragment: <% Dim stream DIM Contents DIM FILENAME DIM FILEEXT Const adtypebinary = 1 Filename = request.querystring ("FILENAME") if filename = "" then Response.write "Invfort file name." Response.end End if 'Below is a file that I don’t want to download Filext = MID (Filename, Instrrev (FILENAME, ".") 1) Select Case UCASE (FileExt) Case "asp", "asa", "aspx", "asax", "MDB" Response.write "Protected files, cannot be downloaded." Response.end End select 'Download this file Response.clear Response.contenttype = "Application/Octet-Stream" Response.addheader "Content-Disposition", "Attachment; FILENAME =" & Filename Set stream = server.createObject ("adodb.stream") Stream.type = adtypebinary Stream.open Stream.loadFromFile Server.mAppath (FILENAME) While Not Stream.eos Response.binarywrite stream.read (1024 * 64) Wend Stream.close Set stream = nothing Response.flush Response.end %> Use: download.asp? FILENAME =/FILES/My.doc Put your doc file on the root directory Files, you can also put it elsewhere. |
<A href = "doublead.asp? FILENAME =/FILES/My.doc"> Click to download Word document </a>