ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 把文件存进access数据库然后取出来供人下载的代码(转)

把文件存进access数据库然后取出来供人下载的代码(转)

原创 Linux操作系统 作者:jcszjswkzhou 时间:2019-03-15 19:18:07 0 删除 编辑
senddate.asp(发送界面)




发给:*


标题:
*


内容:



附件:
(不能超过100K)





*************************************************************************
senddateindb.asp(把要发送的文件保存到数据库)

<!--#INCLUDE FILE="asp/fupload.inc"-->
<!--#include file="asp/opendb.asp"-->
<!--#include file="asp/sqlstr.asp"-->
<!--#include file="asp/checked.asp"-->
<!--#include file="asp/bgsub.asp"-->
<%
'On Error Resume Next
oabusyname=request.cookies("oabusyname")
oabusyusername=request.cookies("oabusyusername")
oabusyuserdept=request.cookies("oabusyuserdept")
oabusyuserlevel=request.cookies("oabusyuserlevel")
if oabusyusername="" then response.redirect "default.asp"
%>






企业管理系统


<%
call bghead()
%>










公文发送




<%
call bgmid()
%>

<%
if Request.ServerVariables("REQUEST_METHOD") = "POST" Then
'---------------------------
'response.write "开始发送
"
'---------------------------
Dim Fields
UploadSizeLimit=100000
Set Fields = GetUpload()
dim Field
For Each Field In Fields.Items
if Field.name="title" then title=BinaryToString(Field.value)
if Field.name="content" then content=BinaryToString(Field.value)
if Field.name="sendto" then sendto=BinaryToString(Field.value)
if Field.name="file1" then
filename=field.FileName
fileContentType=field.ContentType
filevalue=field.value
end if
next
'--------------------------------------
'response.write "title=" & title & "
"
'response.write "content=" & content & "
"
'response.write "sendto=" & sendto & "
"
'response.write "filedname=" & filename & "
"
'response.write "fileContentType=" & fileContentType & "
"
'----------------------------------------
dim mysendto
mysendto=split(sendto,"|",-1,1)
for each sendtoinf in mysendto
userdeptpoint=InStr(sendtoinf,":")
if userdeptpoint>0 then
sendtoinflen=len(sendtoinf)
recipientusername=right(sendtoinf,sendtoinflen-userdeptpoint)
if recipientusername="所有人" then
recipientusername="所有人"
else
usernamepoint=Instr(recipientusername,"(")
usernamelen=len(recipientusername)
recipientusername=left(recipientusername,usernamelen-1)
recipientusername=right(recipientusername,usernamelen-1-usernamepoint)
end if
recipientuserdept=left(sendtoinf,userdeptpoint-1)
set conn=opendb("oabusy","conn","accessdsn")
set rs=server.createobject("ADODB.recordset")
sql = "select * from senddate"
rs.Open sql,conn,1,3
rs.addnew
rs("title")=title
rs("content")=content
rs("sender")=oabusyusername
rs("recipientusername")=recipientusername
rs("recipientuserdept")=recipientuserdept
if filename<>"" then
rs("filename")=filename
rs("fileContentType")=fileContentType
rs("filevalue").appendchunk filevalue
end if
rs.update
rs.close
set rs=nothing
set conn=nothing

end if

next

%>



发送完成

<%
end if
%>
<%
call bgback()
%>

*****************************************************************
listsendfile.asp (把数据库里面的文件取出来并下载,如果是文本或图像会直接打开)
<!--#include file="asp/opendb.asp"-->
<%
set conn=opendb("oabusy","conn","accessdsn")
Set rs=Server.CreateObject("ADODB.recordset")
'request("id")是从上一个文件传过来的值,表示这个文件在数据库里的位置
sql="select filevalue,fileContentType from senddate where id=" & trim(request("id"))
rs.open sql,conn,1,1
Response.ContentType = rs("fileContentType")
Response.BinaryWrite rs("filevalue").getChunk(7500000)
rs.close
set rs=nothing
set conn=nothing
%>


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10294527/viewspace-124680/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2007-08-29

  • 博文量
    923
  • 访问量
    588220