TXT.WORD文档下载另存为,而不是在浏览器中打开
来源:csdn 发布时间:2007-10-25 11:43:00
TXT文本文件,WORD文档点击后弹出另存为对话框,然后保存下载,而不是在浏览器中打开的asp实现方法,使用了asp中的stream对象,同理其它类型的文件只要在ContentType中声明了,就可以下载了。
<%
Response.Buffer=true
取得要下载的文件,如果不为空。就下载
dim url,trueurl
url="下载文件路径和下载文件名"
fname=Request("filename")
if fname<>"" then
trueurlurl=server.MapPath("/") &url
end if
set objFso=server.CreateObject("scripting.filesystemobject")
set fn=objFso.GetFile(trueurl)
flsize=fn.size
flname=fn.name
set fn=nothing
set objFso=nothing
set objStream=server.CreateObject("adodb.stream")
objStream.Open
objStream.Type=1
objStream.LoadFromFile url
select case lcase(right(flname,4))
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 ".txt"
ContentType="text/plain"
Case ".asp", ".ASA", "aspX", "ASAX", ".MDB"
Response.Write "受保护文件,不能下载."
Response.End
case else
ContentType="appliation/octet-stream"
end select
Response.AddHeader "Content-Disposition", "attachment; filename="&flname
Response.AddHeader "Content-Length", flsize
Response.CharSet="UTF-8"
Response.ContentType=ContentType
Response.BinaryWrite objStream.Read
Response.Flush
Response.Clear()
objStream.Close
set objStream=nothing
%>
猜你喜欢
- 很多用户在网站上会糊弄填写一个电子信箱,请问有什么办法可以阻止这种行为?我们通常用两种方法来进行判断:第一种,设定只有形如aspxhome@
- 1. 首先 进入cmd, 输入python,看python是否安装成功说明python安装,没有问题2. 修改注册表第一步window +
- 安装 JSX 插件在 Vue2 中要想使用 jsx 开发,需要安装 @vue/babel-preset-jsx 等插件,之后在 babel
- ASP是Web上的客户机/服务器结构的中间层,虽然它使用脚本语言(Java Script,VB Script等)编写,程序代码在服务器上运行
- 本文是使用pycharm下的pytorch框架编写一个训练本地数据集的Resnet深度学习模型,其一共有两百行代码左右,分成mian.py、
- 下面先看下js禁止右击保存图片。禁止鼠标右键保存图片<img src="" oncontextmenu="
- 所谓类属性的延迟计算就是将类的属性定义成一个property,只在访问的时候才会计算,而且一旦被访问后,结果将会被缓存起来,不用每次都计算。
- 前言使用 pymongo 进行 group by 操作有两种基本方式,他们都是 mongodb 的原生命令,于 Collection 对象上
- 在VirtualBox中使用Ubuntu虚拟机中,会出现虚拟硬盘不够用的情况:查了一下磁盘空间,如下所示:df -H启动CMD命令行,进入V
- //********************************************************************
- 如何通过表单创建一个Word?举个例子吧,我们先创建一个表单文件docform.htm,再用ASP程序(doccreate.asp)来处理表
- 由于计算机软件的非法复制,通信的泄密、数据安全受到威胁。一般为了安全,会要求将数据库名称、密码等信息进行加密。所以加密在开发过程中是经常使用
- 前言mysql是高版本,当执行group by时,select的字段不属于group by的字段的话,sql语句就会报错。错误提示:this
- #创建触发器,当往order表中添加记录是,更新goods表 delimiter $ CREATE TRIGGER trigger1 AFT
- 简介Python Fire是谷歌开源的一个第三方库,用于从任何Python对象自动生成命令行接口(CLI),可用于如快速拓展成命令行等形式。
- 关于MySQL的事务隔离级别,相信很多读者都不陌生,网商有很多种相关的文章,很多人对于各种隔离级别,以及不同的级别可以解决的一些读现象都是如
- 用采集程序的优点有:无须维护网站,因为采集程序中的数据来自其他网站,它将随着该网站的更新而更新;可以节省服务器资源,一般采集程序就几个文件,
- 对Vue全家桶有基本的认知.用有node环境了解express一丶业务分析1.什么情况下进行权限验证?访问敏感接口前端向后端敏感接口发送aj
- 在大学,有很多喜欢的课是需要抢的。但是,这个课的人数和座位都是有限的,今天这个教程教你如何抢到座位,有座位了还怕听不到课吗?赶紧学起来吧,真
- <%@ page language="java" import="java.util.*" p