asp图片下载弹出下载对话框而不是直接打开

知识标签: asp/access/IIS/mssql
asp下载图片的代码如下:
call download(server.mappath("./test.jpg"))
Function download(File)
      temp = Split(File, "\")
      filename = temp(UBound(temp))
      Set s = CreateObject("adodb.stream")
      s.mode = 3
      s.Type = 1
      s.Open
      s.loadfromfile(File)
      data = s.Read
      If IsNull(data) Then
          response.Write "空"
      Else
          response.Clear
          Response.ContentType = "application/octet-stream"
          Response.AddHeader "Content-Disposition", "attachment; filename=" & filename
          response.binarywrite(data)
      End If
      Set s = Nothing
End Function
上面asp下载图片的代码本人亲测成功,可以根据自己需要来做修改。
沪ICP备09053415号 © 赶知识网