• ----:)欢迎访问源码网(:----
    • 首页
    • 博客
    • 学院
    • 下载
    • 论坛
    • 影视
    • 发布源码
    • RSS
    • ITPig
    • 笑话网
    • 百家姓
    • 繁體中文

源码网 - 中国第一源码门户
选择镜像:网通镜像 - 电信主站
  • 首 页
  • 新闻动态
  • 网站运营
  • 网页制作
  • WEB开发
  • 编程开发
  • 图像媒体
  • 操作系统
  • 数据库
  • 服务器
热门搜索 优化 SEO 故事 cms IIS7 MySQL 个人 AdSense 主题推广 | 文章搜索: 高级搜索
会员登录/控制面版您的位置: 学院首页 >> WEB开发 >> ASP开发 >> ASP应用 >> 详细内容
 

推荐文章

 
 

热点文章

  • ASP计算汉字笔画程序代码
  • 身份证查询的ASP版Ajax服务器端,不需要数据库支持
  • ASP入门教程(留言板)
  • ASP小偷程序的原理
  • 用文本+ASP打造新闻发布系统/图片上传
  • ASP实现的日历,可以根据需要在日期上添加任何的操作
  • 利用ADODB.Stream使用浏览器下载服务器文件
  • 超级留言本制作实例
  • Asp深度揭密
  • t0nsha's留言板代码
  • 无组件上传图片到数据库中,最完整解决方案
  • ASP操作Excel技术总结
 
 

相关文章

  • 用ASP创建多栏选项列表
  • 用户状态维护
  • ASP3.0中的流控制能力
  • session的几个问题
  • 分页显示的例子(显示记录背景色替换变化)
  • 编写ASP时用JScript好还是用VBScript好?
  • 域名登记查询(whois)很复杂吗
  • LINE9的目录浏览源程序
  • 谈谈对于ASP+ PDC bits的经验
  • 浅析数据完整性问题
  • 下载文件的代码
  • 不用Golobal.asa和session实现在线人数统计
 
 

百度搜索

 
 

利用ADODB.Stream使用浏览器下载服务器文件

  • 阅览次数:
  • 文章来源: 网海之贝
  • 原文作者: 佚名
  • 整理日期: 2006-10-03
  • 发表评论
  • 字体大小:
  • 小
  • 中
  • 大

download.asp?file=相对路径的文件
就可以把这个文件下载下来

<%  
2  
3 call downloadFile(replace(replace(Request("file"),"",""),"/",""))  
4  
5 Function downloadFile(strFile)  
6 ' make sure you are on the latest MDAC version for this to work  
7 ' -------------------------------------------------------------  
8  
9  
10 ' get full path of specified file  
11 strFilename = server.MapPath(strFile)  
12  
13  
14 ' clear the buffer  
15 Response.Buffer = True  
16 Response.Clear  
17  
18 ' create stream  
19 Set s = Server.CreateObject("ADODB.Stream")  
20 s.Open  
21  
22 ' Set as binary  
23 s.Type = 1  
24  
25 ' load in the file  
26 on error resume next  
27  
28  
29 ' check the file exists  
30 Set fso = Server.CreateObject("Scripting.FileSystemObject")  
31 if not fso.FileExists(strFilename) then  
32 Response.Write("<h1>Error:</h1>" & strFilename & " does not exist<p>")  
33 Response.End  
34 end if  
35  
36  
37 ' get length of file  
38 Set f = fso.GetFile(strFilename)  
39 intFilelength = f.size  
40  
41  
42 s.LoadFromFile(strFilename)  
43 if err then  
44 Response.Write("<h1>Error: </h1>" & err.Description & "<p>")  
45 Response.End  
46 end if  
47  
48 ' send the headers to the users browser  
49 Response.AddHeader "Content-Disposition", "attachment; filename=" & f.name  
50 Response.AddHeader "Content-Length", intFilelength  
51 Response.CharSet = "UTF-8"  
52 Response.ContentType = "application/octet-stream"  
53  
54 ' output the file to the browser  
55 Response.BinaryWrite s.Read  
56 Response.Flush  
57  
58  
59 ' tidy up  
60 s.Close  
61 Set s = Nothing  
62  
63  
64 End Function  
65  
66 %>  

上一篇:Asp深度揭密
下一篇:比AcdSee功能还强大的图片处理、编辑软件,推荐下载!
  • 网友评论:
  • 查看所有评论
  • 我要发表评论
您的网名:
留言主题:
你要发表的内容:

 

关于本站 | 广告联系 | 版权声明 | 网站地图 | 发布软件 | 帮助中心 | 源码论坛

Copyright © 2005-2007 CodePub.Com  程序支持:木翼  滇ICP备05005971号