文件下载函数
2006-11-20 01:36
375 查看
<%
Function downloadFile(strFile)
strFilename=server.MapPath(strFile)
Response.Buffer=True
Response.Clear
Set s=Server.CreateObject("ADODB.Stream")
s.Open
s.Type=1
on error resume next
Set fso=Server.CreateObject("scripting.FileSystemObject")
if not fso.FileExists(strFilename) then
Response.Write("<p>Error:" & strFilename & "Nohave..</p>")
Response.End
end if
Set f=fso.GetFile(strFilename)
intFilelength=f.size
s.LoadFromFile(strFilename)
if err then
Response.Write("Path Error.")
Response.End
end if
Response.AddHeader "Content-Disposition","attachment;filename=" & f.name
Response.AddHeader "Content-Length",intFilelength
Response.CharSet="UTF-8"
Response.ContentType="application/octet-stream"
Response.BinaryWrite s.Read
Response.Flush
s.Close
Set s=Nothing
End Function
Call downloadFile(f_path)
%>
Function downloadFile(strFile)
strFilename=server.MapPath(strFile)
Response.Buffer=True
Response.Clear
Set s=Server.CreateObject("ADODB.Stream")
s.Open
s.Type=1
on error resume next
Set fso=Server.CreateObject("scripting.FileSystemObject")
if not fso.FileExists(strFilename) then
Response.Write("<p>Error:" & strFilename & "Nohave..</p>")
Response.End
end if
Set f=fso.GetFile(strFilename)
intFilelength=f.size
s.LoadFromFile(strFilename)
if err then
Response.Write("Path Error.")
Response.End
end if
Response.AddHeader "Content-Disposition","attachment;filename=" & f.name
Response.AddHeader "Content-Length",intFilelength
Response.CharSet="UTF-8"
Response.ContentType="application/octet-stream"
Response.BinaryWrite s.Read
Response.Flush
s.Close
Set s=Nothing
End Function
Call downloadFile(f_path)
%>
相关文章推荐
- .net 文件点击下载函数 记录
- 收藏:ASP.NET提供文件下载函数(支持大文件、续传、速度限制、资源占用小)
- ASP.NET文件下载函数
- ASP.NET提供文件下载函数
- ASP.NET文件下载函数(好用的东东)
- php利用header函数实现文件下载时直接提示保存_php技巧_脚本之家
- java 木马开发(6)---服务端 --- 文件下载函数
- ASP.NET提供文件下载函数(支持大文件、续传、速度限制、资源占用小)
- php下载文件的函数
- Thinkphp框架下封装文件下载函数
- php 下载文件的函数
- ASP.NET提供文件下载函数(支持大文件、续传、速度限制、资源占用小)
- 文件下载函数
- (摘录)ASP.NET提供文件下载函数(支持大文件、续传、速度限制、资源占用小)
- ASP.ENT C# 文件下载函数
- 【原创】ASP.ENT C# 文件下载函数
- .net 文件点击直接下载函数 记录
- ASP.NET提供文件下载函数(支持大文件、续传、速度限制、资源占用小)
- php利用header函数实现文件下载时直接提示保存