日期:2014-05-17  浏览次数:21285 次

RESPONSE.ADDHEADER的使用
找了好久都没找见这个方法的使用说明不知道在哪儿找?请高手给指点以下.
顺便帮忙解释以下以下几个句子的作用是:
Response.AddHeader   "Content-Disposition ",   "attachment;   filename= "   &   f.name  
Response.AddHeader   "Content-Length ",   intFilelength  
Response.CharSet   =   "UTF-8 "  
Response.ContentType   =   "application/octet-stream "  
是干吗的?
还有这是我用别人编写的一个下载文件的程序.当下载之后链接到这个下载网页的网页上的字体都变了   ,而且我再下载别的文件就不能下载?
高手请指点迷津。
call   downloadFile   (replace(replace(Request.QueryString( "file "), "\ ", " "), "/ ", " "))
Function   downloadFile(strFile)  
strFilename   =   server.MapPath(strFile)  
 
'   clear   the   buffer  
Response.Buffer   =   True  
Response.Clear  
 
'   create   stream  
Set   s   =   Server.CreateObject( "ADODB.Stream ")  
s.Open  
 
'   Set   as   binary  
s.Type   =   1  
 
'   load   in   the   file  
on   error   resume   next  
   
'   check   the   file   exists  
Set   objFileSystem   =   Server.CreateObject( "Scripting.FileSystemObject ")  
if   not   objFileSystem.FileExists(strFilename)   then  
Response.Write( " <h1> Error: </h1> "   &   strFilename   &   "   does   not   exist <p> ")  
Response.End  
end   if  
 
'   get   length   of   file  
Set   f   =   objFileSystem.GetFile(strFilename)  
intFilelength   =   f.size  
 
s.LoadFromFile(strFilename)  
if   err   then  
Response.Write( " <h1> Error:   </h1> "   &   err.Description   &   " <p> ")  
Response.End  
end   if    
'   send   the   headers   to   the   users   browser  
Response.AddHeader   "Content-Disposition ",   "attachment;   filename= "   &   f.name  
Response.AddHeader   "Content-Length ",   intFilelength  
Response.CharSet   =   "UTF-8 "  
Response.ContentType   =   "application/octet-stream "    
'   output   the   file   to   the   browser  
Response.BinaryWrite   s.Read  
Response.Flush    
'   tidy   up
s.Close  
Set   s   =   Nothing  
Set   objFileSystem   =   Nothing  
End   Function  
%>

------解决方案--------------------
Response.AddHeader "Content-Disposition ", "attachment; filename= " & f.name 表示是一个附件.指定文件名. Response.AddHeader "Content-Length ", intFilelength 整个文件长度 Response.CharSet = "UTF-8 " 编码. Response.ContentType = "application/octet-stream " 文件类型 流 还有这是我用别人编写的一个下载文件的程序.当下载之后链接到这个下载网页的网页上的字体都变了 ,而且我再下载别的文件就不能下载? 高手请指点迷津。 ============== 下载时 try: <a target= '_new '