文章选自 http://www.doc88.com/p-331763186969.html ASP: TXT WORD文件下载在本地而不是在浏览器中打开 Response. Bufrer-true 取得要下载的文件,如果不为空。就下载 dim url, trueurl url=”下载文件路径和下载文件名 fname=Request("filename") if frames" then trueurlurl-server. MapPath("/")&url end if set objFso-server. CreateObject("scripting filesystemobject ") set fi-obj Fso Get File(trueurl) flsizefn size fname=fn. name set nothing set objFso-nothing set objStream=server CreateObject("adodb. stream") objStream. Open objStream Type-l objStream LoadFromFile url select case lcase(right(flame, 4) ContentType="video/x-ms-asf" case avi ContentType-"video/avi!" case ContentType"application/msword ContentType="application/zip case.X ContentType=application/vnd. ms-excel case ContentType="image/gif case . JPg Jpeg ContentType"image/jpeg case"way' ContentType=audio/wav case". mp3 ContentType case.mpg, mpeg case ContentType="application/rtf case",htm""html" ContentType=text/html case tXU ContentType"text/plain Case "ASP", " ASa","ASPX","ASAX".". MDB Response。wie"受保护文件不能下载 Response. End case else ContentType=appliation/octet-strean end select Response. AddHeader"Content-Disposition","attachment; filename"&flname Response. AddHeader"Content-Length, flsize Response. CharSet=UTF-8" Response Content Content Typ Response. Binary Write objStream Read Response. Flush Response. Clear objStream. Close set objstream-nothing
|