1、<a href="Download.asp?id=<%=rs("id")%>">资源下载</a>
2、Download.asp <!--#include file="conn.asp"--> <% From_url = Cstr(Request.ServerVariables("HTTP_REFERER")) Serv_url = Cstr(Request.ServerVariables("SERVER_NAME")) if mid(From_url,8,len(Serv_url)) <> Serv_url then response.write "非法链接!" '防止盗链 response.end end if if session("title")="" then response.Write "<script>alert('请注册会员后再下载!');window.location='reg.asp';</script>" response.End() end if if(request.querystring("id") <> "") then 'response.Write("<center>文件不存在,可能被管理员删除</center>") 'response.End() colname = request.querystring("id") end if set rs=server.CreateObject("adodb.recordset") rs.open"select * from user0831",conn,1,1 if rs("sh")=0 then response.Write "<script> alert('您注册的用户尚未审核,等待管理员审核通过后再下载!');history.back(-1);</script>';</script>" response.End() elseif rs("sh")=1 then 'url="soft_url"+request("url") sql="select * from [zlxz] where id="&colname&"" set rs=server.createobject("adodb.recordset") rs.open sql,conn,1,1
downurl=rs("zl") softname=rs("title") FileExt = Mid(downurl, InStrRev(downurl, ".") + 1) F_Ext=UCase(FileExt) if lcase(left(downurl,7))="http://" or lcase(left(downurl,6))="ftp://" then response.redirect downurl else Dim Stream Dim Contents Dim FileName Dim TrueFileName Dim FileExt Const adTypeBinary = 1 Response.Clear Response.ContentType = "application/ms-download" Response.AddHeader "content-disposition", "attachment; filename="&softname&"." & F_Ext & "" Set Stream = server.CreateObject("ADODB.Stream") Stream.Type = adTypeBinary Stream.Open Stream.LoadFromFile Server.MapPath(""&downurl&"") While Not Stream.EOS Response.BinaryWrite Stream.Read(1024 * 64) Wend Stream.Close Set Stream = Nothing Response.Flush Response.End end if rs.close set rs=nothing end if %> |