日期:2014-05-18  浏览次数:20545 次

如何实现文件下载??
Response.Clear();
  Response.ClearHeaders();
  Response.Buffer = false;
  Response.ContentType = "application/octet-stream";
  Response.AppendHeader("Content-Disposition", "attachment;filename=" + dizhi);
  Response.AppendHeader("Content-Length", dizhi.Length.ToString());
  Response.WriteFile(dizhi);
  Response.Flush();
  Response.End();  

假如我的站是www.xx.com 下载的dizhi是http://www.cc.com/aa.rar 要如何实现下载啊?SOS

------解决方案--------------------
<a href='http://www.cc.com/aa.rar' >下载</a>
------解决方案--------------------
www.ebookit.cn以流的形式输出就成了,看我的网站,有介绍
------解决方案--------------------
Dim filename As String = Request.QueryString("filename")
If Not filename = String.Empty Then
filename = Server.MapPath(".") & "\Upload\" & filename

Dim stream
stream = Server.CreateObject("adodb.stream")
stream.open()
stream.type = 1
stream.loadFromFile(filename)
Response.AddHeader("Content-Disposition", "attachment; filename=" & Replace(Server.UrlEncode(System.IO.Path.GetFileName(filename)), "+", " "))
Response.AddHeader("Content-Length", stream.Size)
Response.Charset = "UTF-8"
Response.ContentType = "application/octet-stream"
Response.BinaryWrite(stream.read)
Response.Flush()
stream.close()
stream = Nothing
Response.End()
Else

看你自己的情况来用。
Response.End()
End If