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

ASP弹出下载提示框问题
dim strFile
strFile = "excel\13.xls"
response.ContentType = "application/OCTET-STREAM" 
response.AddHeader "content-disposition","attachment; filename="&strFile

弹出提示框后显示下载的文件名为excel_13.xls了,查了半天百度也没弄明白,请高手指教下,如何显示正确文件名。

------解决方案--------------------
指定路径没有用,下载的时候是不会认你的路径的。
------解决方案--------------------
VBScript code
Sub DownLoadFile(filename,contenttype)
  Dim  fileContentType, stream, filePath
  filePath=server.mappath(filename)
  Set stream = Server.CreateObject("adodb.stream")
  stream.Open
  stream.Type = 1
  stream.LoadFromFile filePath
  Response.AddHeader "Content-Disposition", "attachment; filename=""" & fileName&""""
  Response.AddHeader "Content-Length", stream.Size
  Response.ContentType = contenttype
  Response.BinaryWrite stream.read
  Response.Flush
  stream.Close
  Set stream = Nothing
  response.End
End Sub

DownLoadFile "excel\13.xls","application/OCTET-STREAM"

------解决方案--------------------
探讨
还有 Response.AddHeader "Content-Disposition", "attachment; filename=""" & fileName&""""
我把文件改成当前目录下的,但下载后的文件是HTML的原文件,是怎么回事?