asp在IE浏览器上下载服务器端的各种文件
也就是说,用户直接提示用户下载,而不是通过浏览器打开一些文件。请注意,在将下列代码复制到ASP文件之后,不要在页面中添加一些非ASP代码,如HTML和Javascript客户端代码。复制代码代码如下所示:
<
--------------------------------------------
响应=缓冲区=真
昏暗的strfilepath,strfilesize,strfilename
const adtypebinary = 1
strfilepath =文件路径
strfilesize =…文件大小可选
strfilename =文件名
响应清晰。
8 ******************************************* 8
你需要在你的服务器上安装MDAC 2.6或mdac2.7
8 ******************************************* 8
集objstream = server.createobject(ADODB。流)
objstream。开放
objstream型= adtypebinary。
objstream.loadfromfile strfilepath
strfiletype = 1例(右(strfilename,4))的文件扩展名的站。长期的。
通过文件扩展判断内容类型
选择案例strfiletype
案。ASF
ContentType =视频/ x-ms-asf
案例。
ContentType =视频/视频
案例,
ContentType = application/msword
案例
ContentType =应用/邮编
案例.xls
ContentType =应用/越南盾。MS Excel
案例。
ContentType =图像/图片
案例
ContentType =图像/ JPEG
案例
ContentType =音频 / WAV
案例,
ContentType =音频 / MPEG3
案例
ContentType =视频/视频
案例.rtf
ContentType =应用程序/文件
案例
ContentType =文本/ HTML
案例
ContentType =文本文件
其他案件
处理所有其他文件
ContentType =应用/字节流
最后选择
response.addheader 的内容配置
response.addheader内容长度strfilesize
响应。字符集=UTF-8
response.contenttype ContentType =
response.binarywrite objstream。读
响应。冲洗
objstream。关闭
集objstream =没有
%>