您的位置:建站学院首页 >> 文章 >> asp技术 >> asp应用
下载文件的代码
这里附下载文件的代码:
download.asp

<%
filename=request.querystring("filename")       '取的文件名
'response.content "../manage/upload/"&filename
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("<h1>Error:</h1>" & strFilename & " does not exist<p>") 
 Response.End 
 end if 
 Set f = fso.GetFile(strFilename) 
 intFilelength = f.size 
 s.LoadFromFile(strFilename) 
 if err then 
 Response.Write("<h1>Error: </h1>" & err.Description & "<p>") 
 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 

downloadFile("下载路径"&filename)
%>

Google
 
Web www.cqxw.net