senddate.asp(发送界面)
1<form action="senddateindb.asp" enctype="multipart/form-data" method="post" name="form3">
2<input name="userdept" type="hidden" value="```
3=firstdept
4```"/>
5<input name="username" type="hidden" value="所有人"/>
6<td align="center"><b>发给:</b></td><td><input name="sendto" onfocus="document.form3.title.focus();" size="60" type="text" value="```
7=sendto
8```"/><font color="red">*</font></td>
9
10<tr>
11<td align="center"><b>标题:</b></td>
12<td><input name="title" size="60" type="text"/><font color="red">*</font></td>
13</tr>
14<tr>
15<td align="center"><b>内容:</b></td>
16<td><textarea cols="60" name="content" rows="9"></textarea></td>
17</tr>
18<tr>
19<td align="center"><b>附件:</b></td>
20<td><input name="file1" size="35" type="file"/>(不能超过100K)</td>
21</tr>
22<tr>
23<td align="center" colspan="2">
24<input name="submit" type="submit" value="发送"/>
25</td>
26</tr></form>
senddateindb.asp(把要发送的文件保存到数据库)
1
2'On Error Resume Next
3oabusyname=request.cookies("oabusyname")
4oabusyusername=request.cookies("oabusyusername")
5oabusyuserdept=request.cookies("oabusyuserdept")
6oabusyuserlevel=request.cookies("oabusyuserlevel")
7if oabusyusername="" then response.redirect "default.asp"
1<html>
2<head>
3<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
4<meta content="Microsoft FrontPage 4.0" name="GENERATOR"/>
5<meta content="FrontPage.Editor.Document" name="ProgId"/>
6<link href="css/css.css" rel="stylesheet"/>
7<title>企业管理系统</title>
8</head>
9<body bgcolor="#eeeeee" leftmargin="5" topmargin="5">
call bghead()
1<center>
2<table>
3<tr>
4<td>
5<b>公文发送</b>
6</td>
7<form action="senddate.asp" method="post" name="form1">
8<td>
9<input type="submit" value="返回"/>
10</td>
11</form>
12</tr>
13</table>
14</center>
call bgmid()
1
if Request.ServerVariables("REQUEST_METHOD") = "POST" Then
'---------------------------
'response.write "开始发送<br/>"
'---------------------------
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 & "<br/>"
'response.write "content=" & content & "<br/>"
'response.write "sendto=" & sendto & "<br/>"
'response.write "filedname=" & filename & "<br/>"
'response.write "fileContentType=" & fileContentType & "<br/>"
'----------------------------------------
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
1<br/><br/>
2<center>发送完成</center>
end if
call bgback()
1</body>
2</html>
listsendfile.asp (把数据库里面的文件取出来并下载,如果是文本或图像会直接打开)
1
2set conn=opendb("oabusy","conn","accessdsn")
3Set rs=Server.CreateObject("ADODB.recordset")
4'request("id")是从上一个文件传过来的值,表示这个文件在数据库里的位置
5sql="select filevalue,fileContentType from senddate where id=" & trim(request("id"))
6rs.open sql,conn,1,1
7Response.ContentType = rs("fileContentType")
8Response.BinaryWrite rs("filevalue").getChunk(7500000)
9rs.close
10set rs=nothing
11set conn=nothing