当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

    摘要: 是不是安装到执行文件目录 c:\program files\microsoft visual studio\common\msdev98\bin里 ......
 ·回报    »显示摘要«
    摘要: 改写您的指点 ......


如何实现链接的文件点击直接下载

asp里如何实现链接的文件点击直接下载,而不是打开文件

NO.1   作者: xanewong111

<%  
  Response.Buffer   =   true  
  Response.Clear  
   
  dim   url  
  Dim   fso,fl,flsize  
  dim   Dname  
  Dim   objStream,ContentType,flName,isre,url1  
  *********************************************调用时传入的下载文件名  
  Dname=trim(Request.QueryString("Dname"))  
  ******************************************************************  
  If   Dname<>""   Then  
  ******************************下载文件存放的服务端目录  
  url=server.MapPath(Dname)  
  ***************************************************  
  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="   &   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  
  %>


    摘要: 我要实现的是修改留痕功能,我希望修改后的文档基础上,自动再生成一个没有痕迹的文档。也就是说,修改一次,就多出一份文档,并且该文档,我可以定义名字。 我希望用在notes里面用代码的形式来加载word中的动作。也就是说,我在designer中写代码,要求word给出动作---比如实现新建,拷贝,及接受修订等动作。 希望可以给出一个大概的想法代码或是例子!!! (难点是如何实现在notes中对......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE