asp 文件下载代码
来源:互联网 发布:大话西游2优化 编辑:程序博客网 时间:2024/05/17 02:37
filepath = "/music/2006522133342.mp3"
filepath = server.mappath(filepath)
Response.buffer = True '开启缓存
Response.ContentType = "audio/x-pn-realaudio" ‘文件类型
Dim objStream
Set objStream = Server.CreateObject("ADODB.Stream") '创建ADODB.stream对象
objStream.Type = 1 '以二进制读取模式
objStream.Open
objStream.LoadFromFile filepath '读取文件
Response.binarywrite objStream.Read '以二进制的方式输出至客户端浏览器
response.Flush() '边缓存边输出
Session("afon")=false '重新设置session为FALSE
objStream.Close
Set objStream = Nothing
filepath = server.mappath(filepath)
Response.buffer = True '开启缓存
Response.ContentType = "audio/x-pn-realaudio" ‘文件类型
Dim objStream
Set objStream = Server.CreateObject("ADODB.Stream") '创建ADODB.stream对象
objStream.Type = 1 '以二进制读取模式
objStream.Open
objStream.LoadFromFile filepath '读取文件
Response.binarywrite objStream.Read '以二进制的方式输出至客户端浏览器
response.Flush() '边缓存边输出
Session("afon")=false '重新设置session为FALSE
objStream.Close
Set objStream = Nothing
附常见的contenttype类型
<%
Function Get_FileTypeAbName(sFileType)
select case sFileType
'图像类
Case "image/gif"
Get_FileTypeAbName="gif"
exit function
Case "image/pjpeg"
Get_FileTypeAbName="jpg"
exit Function
Case "image/bmp"
Get_FileTypeAbName="bmp"
exit Function
Case "image/png"
Get_FileTypeAbName="png"
exit Function
Case "image/tif"
Get_FileTypeAbName="tif"
Exit Function
'音频类
Case "audio/mpeg"
Get_FileTypeAbName="mp3"
Exit Function
Case "audio/x-ms-wma"
Get_FileTypeAbName="wma"
Exit Function
Case "audio/mid"
Get_FileTypeAbName="mid"
Exit Function
Case "audio/wav"
Get_FileTypeAbName="wav"
Exit Function
'视频类
Case "application/vnd.rn-real media"
Get_FileTypeAbName="rm"
Exit Function
Case "video/x-ms-wmv"
Get_FileTypeAbName="wmv"
Exit Function
'flash
Case "application/x-shockwave-flash"
Get_FileTypeAbName="swf"
Exit Function
'压缩软件类
Case "application/x-zip-compressed"
Get_FileTypeAbName="zip"
Exit Function
Case "application/octet-stream"
Get_FileTypeAbName="rar"
Exit Function
'文本类
Case "text/plain"
Get_FileTypeAbName="txt"
Exit Function
Case "text/html"
Get_FileTypeAbName="html"
Exit Function
Case "application/msaccess"
Get_FileTypeAbName="mdb"
Exit Function
Case "application/msword"
Get_FileTypeAbName="doc"
Exit Function
Case "application/vnd.ms-excel"
Get_FileTypeAbName="xls"
Exit Function
end select
End Function
%>
Function Get_FileTypeAbName(sFileType)
select case sFileType
'图像类
Case "image/gif"
Get_FileTypeAbName="gif"
exit function
Case "image/pjpeg"
Get_FileTypeAbName="jpg"
exit Function
Case "image/bmp"
Get_FileTypeAbName="bmp"
exit Function
Case "image/png"
Get_FileTypeAbName="png"
exit Function
Case "image/tif"
Get_FileTypeAbName="tif"
Exit Function
'音频类
Case "audio/mpeg"
Get_FileTypeAbName="mp3"
Exit Function
Case "audio/x-ms-wma"
Get_FileTypeAbName="wma"
Exit Function
Case "audio/mid"
Get_FileTypeAbName="mid"
Exit Function
Case "audio/wav"
Get_FileTypeAbName="wav"
Exit Function
'视频类
Case "application/vnd.rn-real media"
Get_FileTypeAbName="rm"
Exit Function
Case "video/x-ms-wmv"
Get_FileTypeAbName="wmv"
Exit Function
'flash
Case "application/x-shockwave-flash"
Get_FileTypeAbName="swf"
Exit Function
'压缩软件类
Case "application/x-zip-compressed"
Get_FileTypeAbName="zip"
Exit Function
Case "application/octet-stream"
Get_FileTypeAbName="rar"
Exit Function
'文本类
Case "text/plain"
Get_FileTypeAbName="txt"
Exit Function
Case "text/html"
Get_FileTypeAbName="html"
Exit Function
Case "application/msaccess"
Get_FileTypeAbName="mdb"
Exit Function
Case "application/msword"
Get_FileTypeAbName="doc"
Exit Function
Case "application/vnd.ms-excel"
Get_FileTypeAbName="xls"
Exit Function
end select
End Function
%>
- asp 文件下载代码
- ASP文件下载代码
- ASP.NET下载文件代码
- ASP.NET下载文件代码
- ASP.NET下载文件代码
- asp.net下载文件实现代码
- asp.net 文件下载实现代码
- 下载Excel文件ASP.NET 代码
- asp.net(c#)文件下载实现代码
- ASP.NET下载文件的代码
- asp中使用流方式下载文件的代码
- ASP.NET上传和下载文件的代码
- asp.net Web Services上传和下载文件(完整代码)
- ASP.NET 大文件下载的实现思路及代码
- ASP.NET 大文件下载的实现思路及代码
- 下载文件 asp.net
- ASP.NET文件下载
- asp.net 文件下载
- System.ServiceModel.ExceptionDetail
- (原创)用TextBox实现日期的输入
- 在eclipse3.2.1中无法覆盖和调用继承的父类方法!
- 方便面
- ILE 下c/c++/cl/RPG等 混合编程
- asp 文件下载代码
- 阶乘之计算从入门到精通-大数的表示
- 让女人晕倒的对白
- 简单导航树代码!
- javascript__表单验证
- 与图片的二进制数据库存储和显示
- 测试 Oracle 中对 char 和 varchar2 两种类型的等值比较
- 2007高校BBS上几个睿智的冷笑话
- 程序运行时间的测量