如何实现点击链接到DOC文件出现下载提示而不是在IE中打开?

anscnu 2004-12-06 10:01:58
如题.

怎样设置最简单?(服务器端设置)
如果不行,能使用asp实现实现?
谢谢指教。
...全文
355 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
kkwu 2005-03-07
  • 打赏
  • 举报
回复
该程序如果下载的文件大与5M,就不能下了,怎么改呀?
mygia 2005-03-01
  • 打赏
  • 举报
回复
好东西
daikaiming 2004-12-06
  • 打赏
  • 举报
回复
同意楼上的
alern_zyb 2004-12-06
  • 打赏
  • 举报
回复
<a target="_blank" href="downattach.asp?Dname=文件名;n=下载文件名>下载</a> 
lingyun2111 2004-12-06
  • 打赏
  • 举报
回复
同意
psoua9 2004-12-06
  • 打赏
  • 举报
回复
需要另外自己写程序,进行调用,如楼上的。
alern_zyb 2004-12-06
  • 打赏
  • 举报
回复
调用这个文件
downattach.asp
<%
Response.Buffer = true
Response.Clear
dim url
Dim fso,fl,flsize
dim Dname
Dim objStream,ContentType,flName,isre,url1
'*********************************************调用时传入的下载文件名
Dname=trim(request("n"))
upname=trim(request("upname"))
'******************************************************************
If Dname<>"" Then
'******************************下载文件存放的服务端目录
url=server.MapPath("comm_info/mail_doc/")&"\"&Dname '“admin/UploadInfor/”为路径名

'***************************************************
End If

Set fso=Server.CreateObject("Scripting.FileSystemObject")
Set fl=fso.getfile(url)
flsize=fl.size
flName=fl.name
Set fl=Nothing
Set fso=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 Else
ContentType = "application/octet-stream"
End Select



Response.AddHeader "Content-Disposition", "attachment; filename=" & upname
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
%>

anscnu 2004-12-06
  • 打赏
  • 举报
回复
to alern_zyb(爱嚼口香糖的程序员)

<a target="_blank" href="downattach.asp?Dname=文件名&n=下载文件名>下载</a> 

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧