关于下载和传输的问题。。。

tianlangxing2002 2002-05-22 12:08:14
各位大虾:
小弟我又有一个问题请教:
我要实现的功能是:1。我要将服务器搜索出来的东东打包(形成一个可以下载的文件,而且是文本形式的)我可以点击下载,就可以将它保存在客户机里
2。 我可以将这个数据包发送到其他客户机里,当然也是文本形式的
我该怎么办?编个控件吗?我不会!如果有例子或其他方法。请指点!!!!
THANK YOU FOR HELPONG ME!!
...全文
40 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
saucer 2002-05-22
  • 打赏
  • 举报
回复
1.文本形式???

如果你只是要把所有的文件集中在一起,那么先给Response设置一个合适的ContentType,把要包含的文件一个个地打开,读出内容,写入Response就行了,如果你要ZIP那些文件的话,参看
http://www.aspfaq.com/show.asp?id=2187

2. 用网络服务器怎么能随便把文件传给其它客户端?这些客户端必须先提出请求,网络服务器才能把文件传过去!
freezwy 2002-05-22
  • 打赏
  • 举报
回复
1.生成一个TXT文件
2.传递这个TXT文件
文件生成就很简单了,关于下载是这样的
<%
call downloadFile("xx.txt")
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 & " does not exist<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>" & err.Description & "<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
' tidy up
s.Close
Set s = Nothing
End Function
%>
julyclyde 2002-05-22
  • 打赏
  • 举报
回复
1 可否使用multipart/mixed实现?
2 肯定需要客户端请求
julyclyde 2002-05-22
  • 打赏
  • 举报
回复
1 可否使用multipart/mixed实现?
2 肯定需要客户端请求
julyclyde 2002-05-22
  • 打赏
  • 举报
回复
1 可否使用multipart/mixed实现?
2 肯定需要客户端请求

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧