首页 > 华企学院 > 源码教程 > TXT.WORD文档下载在本地,而不是在浏览器中打开源码精华教程

TXT.WORD文档下载在本地,而不是在浏览器中打开源码精华教程

作者:华企商城小编  浏览量:71   发布时间:2014-11-08 15:49:24

   TXT.WORD文档下载在本地,而不是在浏览器中打开源码精华教程

<%< /> 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< /> %>< /> <%

  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

  %>

华企商城更多商品介绍:医院网站模板    百度口碑评价软件  医疗器械php门户网站源码

文章转载请注明出处:http://www.netshop168.com/article-163.html


精品推荐
下一篇:网站源码上传有有关教程
上一篇:为什么要优化WordPress数据库?
相关文章

华人企业网
关注微信公众号
享受更多优惠

 

消费者最喜爱的网站TOP100 | | 网络社会征信网 | 北京工商 | 法律顾问 | 京ICP备07504386号-6 | 网站地图