[高分求救] asp下载链接错误!~

来源:百度知道 编辑:UC知道 时间:2024/04/25 10:19:16
文字[下栽]链接到 down_files.asp
down_files.asp的代码如下:
<!--#include file="../inc/conn.asp"-->
<%
set rs = server.CreateObject ("Adodb.recordset")
sql = "select * from files where id="&cint(request("id"))&""
rs.open sql,conn,1,1
do while not rs.eof
dim filename,filepath
filename1=trim(rs("filename"))
filepath1=trim(rs("filepath"))
rs.MoveNext
loop
rs.Close
set rs=nothing

Const adTypeBinary = 1
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile Server.MapPath("&filepath1&")
Response.ContentType = "application/octet-stream"
Response.AddHeader "Content-Disposition", "attachment; filename=&filename1&"
Response.BinaryWrite objStream.Read
Response.Flush<

do while not rs.eof
dim filename,filepath
filename1=trim(rs("filename"))
filepath1=trim(rs("filepath"))
rs.MoveNext
loop

你这里为什么要使用循环呢?
没看出你的代码中有需要使用循环的地方啊

循环不要就去掉试试

看看提示什么错误才好帮你解决

<%
set rs = server.CreateObject ("Adodb.recordset")
sql = "select * from files where id="&cint(request("id"))
rs.open sql,conn,1,1
if not rs.eof then
dim filename,filepath
filename1=trim(rs("filename"))
filepath1=trim(rs("filepath"))
end if
rs.Close
set rs=nothing

response.write Server.MapPath("&filepath1&") '测试一下是否是真实地址
response.end '测试完成后,删除些行

你把filepath1输出看看正不正确,

你Server.MapPath("&filepath1&")
这个这样写干什么呀?

Server.MapPath("filepath1") 直接这样不行啊?