主题:ASP客户端多文件下载?? 高手请进
ASP客户端多文件下载??
<%
Set myRecordset=Server.CreateObject("ADODB.RecordSet")
sql="select *from scanline"
myRecordset.Open sql,"DSN=zjp_test;"
do while not myRecordset.EOF
downloadFile(myRecordset(1))
myRecordset.MoveNext
loop
%>
//scanline表中只有两个字段,myRecordset(1)为文件虚拟路径名;
<%
Function downloadFile(strFile)
' make sure you are on the latest MDAC version for this to work
' -------------------------------------------------------------
' get full path of specified file
strFilename = server.MapPath(strFile)
' clear the buffer
Response.Buffer = True
Response.Clear
' create stream
Set s = Server.CreateObject("ADODB.Stream")
s.Open
' Set as binary
s.Type = 1
' load in the file
on error resume next
' check the file exists
Set fso = Server.CreateObject("Scripting.FileSystemObject")
if not fso.FileExists(strFilename) then
Response.Write("<h1>Error:</h1>" & strFilename & " 文件不存在<p>")
Response.End
end if
' get length of file
Set f = fso.GetFile(strFilename)
'intFilelength = f.size
s.LoadFromFile(strFilename)
if err then
'Response.Write("<h1>Error: </h1>" 文件下载错误 "<p>")
Response.End
end if
' send the headers to the users browser
Response.AddHeader "Content-Disposition", "attachment; filename="&f.name
Response.AddHeader "Content-Length", intFilelength
Response.CharSet = "UTF-8"
Response.ContentType = "application/octet-stream"
' output the file to the browser
Response.BinaryWrite s.Read
Response.Flush
Response.End()
' tidy up
s.Close
Set s = Nothing
End Function
%>
该代码只能实现表中第一条记录的客户端下载.
怎样才能实现对该字段所有记录的客户端下载?
谢谢
<%
Set myRecordset=Server.CreateObject("ADODB.RecordSet")
sql="select *from scanline"
myRecordset.Open sql,"DSN=zjp_test;"
do while not myRecordset.EOF
downloadFile(myRecordset(1))
myRecordset.MoveNext
loop
%>
//scanline表中只有两个字段,myRecordset(1)为文件虚拟路径名;
<%
Function downloadFile(strFile)
' make sure you are on the latest MDAC version for this to work
' -------------------------------------------------------------
' get full path of specified file
strFilename = server.MapPath(strFile)
' clear the buffer
Response.Buffer = True
Response.Clear
' create stream
Set s = Server.CreateObject("ADODB.Stream")
s.Open
' Set as binary
s.Type = 1
' load in the file
on error resume next
' check the file exists
Set fso = Server.CreateObject("Scripting.FileSystemObject")
if not fso.FileExists(strFilename) then
Response.Write("<h1>Error:</h1>" & strFilename & " 文件不存在<p>")
Response.End
end if
' get length of file
Set f = fso.GetFile(strFilename)
'intFilelength = f.size
s.LoadFromFile(strFilename)
if err then
'Response.Write("<h1>Error: </h1>" 文件下载错误 "<p>")
Response.End
end if
' send the headers to the users browser
Response.AddHeader "Content-Disposition", "attachment; filename="&f.name
Response.AddHeader "Content-Length", intFilelength
Response.CharSet = "UTF-8"
Response.ContentType = "application/octet-stream"
' output the file to the browser
Response.BinaryWrite s.Read
Response.Flush
Response.End()
' tidy up
s.Close
Set s = Nothing
End Function
%>
该代码只能实现表中第一条记录的客户端下载.
怎样才能实现对该字段所有记录的客户端下载?
谢谢

您所在位置: