<!--#include file="system/Conn.asp"--><%

id=Request.QueryString("id")
If id="" Or Not IsNumeric(id) Then id=0
If id<=0 Then Conn.Close:Set Conn=Nothing:Response.Write "<script>top.location.href='/index.asp'</script>":Response.End
Set Rs=Server.CreateObject("ADODB.RecordSet")


Rs.Open "Select damc,daurl From da Where dastate>0 And id="&id,Conn,1,1
If Not Rs.Bof And Not Rs.Eof Then
	damc=Rs("damc"):daurl = Replace(Rs("daurl"),"&#95;","_")

	Set Fs = Server.CreateObject("Scripting.FileSystemObject")
	Set Ado = Server.CreateObject("Adodb.Stream")
	i = 0
	r = 1024
	FilePath = Server.MapPath(daurl)
	File_type = Fs.GetExtensionName(FilePath)

	'Response.Write Fs.GetFile(FilePath).name:Response.End
	Ado.Mode = 3
	Ado.Type = 1
	Ado.Open
	
	Ado.LoadFromFile(FilePath)
	'Response.AddHeader "Content-Disposition", "attachment; filename=" & Server.UrlEncode(damc)&"."&File_type	'Fs.GetFile(FilePath).name
	Response.AddHeader "Content-Disposition", "inline; filename=" & Server.UrlEncode(damc)&"."&File_type	'Fs.GetFile(FilePath).name
	Response.AddHeader "Content-Length", Ado.size
	Response.ContentType = "application/octet-stream"
	While i < Ado.Size
	Response.BinaryWrite Ado.Read(r)
	Response.Flush
	i = i + r
	Wend
	Ado.Close
	Set Ado=Nothing
	Set Fs=Nothing
Response.End

Else
	Response.Write "<script>alert('没有找到您需要的资料');top.location.href='/index.asp'</script>"
End If
Rs.Close:Set Rs=Nothing:Conn.Close:Set Conn=Nothing
%>