📄 把文件存进access数据库然后取出来供人下载的代码.htm
字号:
color=#ceffff>ASP应用</FONT></A> >>
《把文件存进access数据库然后取出来供人下载的代码》</FONT></TD></TR>
<TR>
<TD bgColor=#586011 colSpan=2 height=1><SPACER type="block"
width="1"></TD></TR>
<TR>
<TD colSpan=2 height=7></TD></TR>
<TR>
<TD align=middle class=p4
colSpan=2><B>把文件存进access数据库然后取出来供人下载的代码</B></FONT><BR>2002-6-13 动网先锋
</TD></TR>
<TR>
<TD class=p4 colSpan=2>
<BLOCKQUOTE><BR>senddate.asp(发送界面)
<P></P>
<P><form method="post" ENCTYPE="multipart/form-data"
name="form3" action="senddateindb.asp"><BR><input
type="hidden" name="userdept"
value="<%=firstdept%>"><BR><input type="hidden"
name="username" value="所有人"><BR><td
align="center"><b>发给:</b></td><td><input
type="text" name="sendto" size=60 value="<%=sendto%>"
onfocus="document.form3.title.focus();"><font
color=red>*</font></td><BR></tr><BR><tr><BR><td
align="center"><b>标题:</b></td><BR><td><input
type=text name="title" size=60><font
color=red>*</font></td><BR></tr><BR><tr><BR><td
align="center"><b>内容:</b></td><BR><td><textarea
name="content" rows="9"
cols="60"></textarea></td><BR></tr><BR><tr><BR><td
align="center"><b>附件:</b></td><BR><td><input
type="file" name="file1"
size=35>(不能超过100K)</td><BR></tr><BR><tr><BR><td
align=center colspan=2><BR><input type="submit"
name="submit" value="发送"><BR></td><BR></form></P>
<P>*************************************************************************<BR>senddateindb.asp(把要发送的文件保存到数据库)</P>
<P><!--#INCLUDE FILE="asp/fupload.inc"--><BR><!--#include
file="asp/opendb.asp"--><BR><!--#include
file="asp/sqlstr.asp"--><BR><!--#include
file="asp/checked.asp"--><BR><!--#include
file="asp/bgsub.asp"--><BR><%<BR>'On Error Resume
Next<BR>oabusyname=request.cookies("oabusyname")<BR>oabusyusername=request.cookies("oabusyusername")<BR>oabusyuserdept=request.cookies("oabusyuserdept")<BR>oabusyuserlevel=request.cookies("oabusyuserlevel")<BR>if
oabusyusername="" then response.redirect
"default.asp"<BR>%><BR><html><BR><head><BR><meta
http-equiv="Content-Type" content="text/html;
charset=gb2312"><BR><meta name="GENERATOR"
content="Microsoft FrontPage 4.0"><BR><meta name="ProgId"
content="FrontPage.Editor.Document"><BR><link
rel="stylesheet"
href="css/css.css"><BR><title>企业管理系统</title><BR></head><BR><body
bgcolor="#eeeeee" topmargin="5"
leftmargin="5"><BR><%<BR>call
bghead()<BR>%><BR><center><BR><table><BR><tr><BR><td><BR><b>公文发送</b>
<BR></td><BR><form action="senddate.asp" method="post"
name="form1"><BR><td><BR><input type="submit"
value="返回"><BR></td><BR></form><BR></tr><BR></table><BR></center><BR><%<BR>call
bgmid()<BR>%></P>
<P><%<BR>if Request.ServerVariables("REQUEST_METHOD") = "POST"
Then<BR>'---------------------------<BR>'response.write
"开始发送<br>"<BR>'---------------------------<BR>Dim
Fields<BR>UploadSizeLimit=100000<BR>Set Fields =
GetUpload()<BR>dim Field<BR>For Each Field In Fields.Items<BR>if
Field.name="title" then title=BinaryToString(Field.value)<BR>if
Field.name="content" then
content=BinaryToString(Field.value)<BR>if Field.name="sendto" then
sendto=BinaryToString(Field.value)<BR>if Field.name="file1"
then<BR>filename=field.FileName<BR>fileContentType=field.ContentType<BR>filevalue=field.value<BR>end
if<BR>next<BR>'--------------------------------------<BR>'response.write
"title=" & title & "<br>"<BR>'response.write
"content=" & content & "<br>"<BR>'response.write
"sendto=" & sendto & "<br>"<BR>'response.write
"filedname=" & filename & "<br>"<BR>'response.write
"fileContentType=" & fileContentType &
"<br>"<BR>'----------------------------------------<BR>dim
mysendto<BR>mysendto=split(sendto,"|",-1,1)<BR>for each sendtoinf
in mysendto<BR>userdeptpoint=InStr(sendtoinf,":")<BR>if
userdeptpoint>0
then<BR>sendtoinflen=len(sendtoinf)<BR>recipientusername=right(sendtoinf,sendtoinflen-userdeptpoint)<BR>if
recipientusername="所有人"
then<BR>recipientusername="所有人"<BR>else<BR>usernamepoint=Instr(recipientusername,"(")<BR>usernamelen=len(recipientusername)<BR>recipientusername=left(recipientusername,usernamelen-1)<BR>recipientusername=right(recipientusername,usernamelen-1-usernamepoint)<BR>end
if<BR>recipientuserdept=left(sendtoinf,userdeptpoint-1)<BR>set
conn=opendb("oabusy","conn","accessdsn")<BR>set
rs=server.createobject("ADODB.recordset") <BR>sql = "select * from
senddate"<BR>rs.Open sql,conn,1,3<BR>rs.addnew
<BR>rs("title")=title<BR>rs("content")=content<BR>rs("sender")=oabusyusername<BR>rs("recipientusername")=recipientusername<BR>rs("recipientuserdept")=recipientuserdept<BR>if
filename<>""
then<BR>rs("filename")=filename<BR>rs("fileContentType")=fileContentType<BR>rs("filevalue").appendchunk
filevalue<BR>end if<BR>rs.update <BR>rs.close <BR>set rs=nothing
<BR>set conn=nothing </P>
<P>end if</P>
<P>next</P>
<P>%><BR><br><br><BR><center>发送完成</center><BR><%<BR>end
if<BR>%><BR><%<BR>call bgback()<BR>%><BR></body>
<BR></html> </P>
<P>*****************************************************************<BR>listsendfile.asp
(把数据库里面的文件取出来并下载,如果是文本或图像会直接打开)<BR><!--#include
file="asp/opendb.asp"--><BR><% <BR>set
conn=opendb("oabusy","conn","accessdsn")<BR>Set
rs=Server.CreateObject("ADODB.recordset")<BR>'request("id")是从上一个文件传过来的值,表示这个文件在数据库里的位置<BR>sql="select
filevalue,fileContentType from senddate where id=" &
trim(request("id")) <BR>rs.open sql,conn,1,1
<BR>Response.ContentType =
rs("fileContentType")<BR>Response.BinaryWrite
rs("filevalue").getChunk(7500000) <BR>rs.close <BR>set rs=nothing
<BR>set conn=nothing <BR>%> <BR><BR></P></BLOCKQUOTE></TD></TR>
<TR>
<TD class=p4 vAlign=top width="50%">
<BLOCKQUOTE>原作者:awayeah<BR>来 源:开发者俱乐部<BR>共有7095位读者阅读过此文<BR>【<A
href="http://bbs.aspsky.net/list.asp?boardid=1">发表评论</A>】
</BLOCKQUOTE></TD>
<TD class=p4 vAlign=top width="50%">
<P>
<LI><FONT color=#0772b1>上篇文章</FONT>:<A
href="http://www.aspsky.net/article/list.asp?id=2742">一个分页存储过程</A>
<BR>
<LI><FONT color=#0772b1>下篇文章</FONT>:<A
href="http://www.aspsky.net/article/list.asp?id=2744">远程获取内容,并将内容存在本地电脑上,包括任何文件</A>
</LI></TD></TR>
<TR>
<TD bgColor=#297dff class=p4 height=20 width="50%"><FONT
color=#ceffff> → 本周热门</FONT></TD>
<TD bgColor=#297dff class=p4 width="50%"><FONT color=#ceffff> →
相关文章</FONT></TD></TR>
<TR>
<TD bgColor=#586011 colSpan=2 height=1><SPACER type="block"
width="1"></TD></TR>
<TR>
<TD colSpan=2 height=7></TD></TR>
<TR>
<TD class=p4 vAlign=top width="50%">
<LI><A href="http://www.aspsky.net/article/list.asp?id=1510"
target=_top title="SQL Server 7.0 入门(一)">SQL Server 7.0
入门(...</A>[<FONT color=red>7239</FONT>]<BR>
<LI><A href="http://www.aspsky.net/article/list.asp?id=1540"
target=_top title=PHP4实际应用经验篇(1)>PHP4实际应用经验篇(1)</A>[<FONT
color=red>7135</FONT>]<BR>
<LI><A href="http://www.aspsky.net/article/list.asp?id=1536"
target=_top
title=无组件文件上传代码实例(支持多文件上传及文件和input域混合上传)>无组件文件上传代码实例(支持多文件上...</A>[<FONT
color=red>6029</FONT>]<BR>
<LI><A href="http://www.aspsky.net/article/list.asp?id=2557"
target=_top title=树型结构在ASP中的简单解决>树型结构在ASP中的简单解决</A>[<FONT
color=red>5757</FONT>]<BR>
<LI><A href="http://www.aspsky.net/article/list.asp?id=1545"
target=_top title=PHP4实际应用经验篇(6)>PHP4实际应用经验篇(6)</A>[<FONT
color=red>5599</FONT>]<BR>
<LI><A href="http://www.aspsky.net/article/list.asp?id=2563"
target=_top title=一个老个写的无组件上传>一个老个写的无组件上传</A>[<FONT
color=red>5013</FONT>]<BR>
<LI><A href="http://www.aspsky.net/article/list.asp?id=1542"
target=_top title=PHP4实际应用经验篇(3)>PHP4实际应用经验篇(3)</A>[<FONT
color=red>4731</FONT>]<BR></LI></TD>
<TD class=p4 vAlign=top width="50%">
<LI><A
href="http://www.aspsky.net/article/list.asp?id=2743">把文件存进access数据库然后取出来供人下载的代码</A><BR>
<LI><A
href="http://www.aspsky.net/article/list.asp?id=2702">利用ADODB.Stream使用浏览器下载服务器文件</A><BR>
<LI><A
href="http://www.aspsky.net/article/list.asp?id=2434">彻底防止ACCESS数据库文件被下载</A><BR>
<LI><A
href="http://www.aspsky.net/article/list.asp?id=931">计算文件下载时间</A><BR></LI></TD></TR>
<TR>
<TD colSpan=2 height=7></TD></TR></TBODY></TABLE>
<TD bgColor=#297dff width=1> </TD></TR></TBODY></TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=755>
<TBODY>
<TR>
<TD bgColor=#297dff height=1><SPACER type="block"
width="1"></TD></TR></TBODY></TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=755>
<TBODY>
<TR>
<TD align=middle height=30></TD></TR></TBODY></TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=755>
<TBODY>
<TR>
<TD align=middle class=p2 width="100%">
<TABLE border=0 cellPadding=0 cellSpacing=0 width=755>
<TBODY>
<TR>
<TD align=middle class=p2 width="100%">
<P align=center><A
href="http://www.aspsky.net/produce/index.asp">客户服务</A> -- <A
href="http://www.aspsky.net/aspads.asp">广告合作</A> -- <A
href="http://www.aspsky.net/about.asp">关于本站</A> -- <A
href="http://www.aspsky.net/tell.asp">联系方法</A><BR><BR>动网先锋版权所有 <FONT
face=Verdana, size=1 Arial, Helvetica, sans-serif>Copyright ©
2000-2001 <B>AspSky<FONT color=#cc0000>.Net</FONT></B>, All Rights
Reserved .</FONT>
</P></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></CENTER></CENTER></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -