今天超无聊,把阳光白雪的函数做了小小的改进,
其实那个路径问题,在写文件名的时候直接写上去也可以,
但是文件下载的时候就会有点小问题
具体的就是:文件名:load 文件类型:未知;
加上一个filepath就可以解决.<% 
'**************************************************************
'**使用方法:                                                **
'**在点击下载处加连接<a href="load.asp?
filepath=文件路径&filename=文件名"></a> **
'**阳光白雪——2005年11月21日                                **
'**E-mail:chenmanyi0818@126.com                              **
'**HomePage:http://www.ec2002.com ;                          **
'**************************************************************
'**修改:hangxj——2007年02月07日                                **
'**E-mail:121sun@163.com                              **
'**HomePage:http://www.hangxj.com ;                          **
'**************************************************
'**              实现文件下载函数                **
'**************************************************
Function Filedownload(filepath,filename) 
  Dim strchar,fliesend,objectFile,objfile,objStream,path,pathtype
  pathtype = "application/x-msdownload" 
  path = server.MapPath(
filepath&filename)
  Const loadfilesize=32768 '32KB,也可取其它值,单位:字节
   '***********************************
  '测试用
  'response.Write(path)
  'response.Write(filename)
  'response.End()
  '***********************************
  fliesend=0 
  TransferFile = True 
  Set objectFile = Server.CreateObject("Scripting.FileSystemObject") 
  Set objfile = objectFile.GetFile(Path) 
  Set objStream = objfile.OpenAsTextStream(1,-1) 
  Response.AddHeader "content-type", pathtype 
  response.AddHeader "Content-Disposition","attachment;filename="&filename 
  Response.AddHeader "content-length", objfile.Size 
   Do While Not objStream.AtEndOfStream 
     strchar = objStream.Read(1) 
     Response.BinaryWrite(strchar) 
     fliesend = fliesend + 1 
     If (fliesend MOD loadfilesize) = 0 Then 
       Response.Flush 
       If Not Response.IsClientConnected Then 
         TransferFile = False 
         Exit Do 
       End If 
     End If 
   Loop
  Response.Flush 
  If Not Response.IsClientConnected Then
    TransferFile = False
  end if
  objStream.Close 
  Set objStream = Nothing 
  Set objectFile = Nothing 
End Function 
'****************************************************
'**               文件下载函数结束                 **
'****************************************************
Dim 
filepath,fileneme,downloadfile 
filepath = request("filepath")  '下载文件的相对路径
filename = request("filename")  '此处的 filename 仅为下载文件的名称(包括扩展名)
downloadfile = Filedownload(filepath,filename) '调用文件下载函数
Response.End
%>