⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 attach.asp

📁 功能齐全的oa系统
💻 ASP
字号:
<%@ Language=VBScript %>
<!-- #include virtual="include/ASPHeader.asp" -->
<!-- #include virtual="include/OpenConnection.asp" -->
<%
	dim intRnd, fso, strPath, fldTemp, sql
	dim objUp, intID, rs, key, File, strFileName, objSave
	intRnd = Request("Rnd")


	'如果是首次编辑草稿箱中的信,则取出数据库中已保存的附件的信息
	if Request("Mode") = "Edit" then
		Session("EditTimes") = session("EditTimes") + 1
		if Session("EditTimes") = 1 then
			sql = "select priAttachID, priMsgAttachName, priMsgAttachSize from PrivateMessageAttach where priMsgID=" & Session("intPriDraftBoxCurMsgID")
			set rs = cn.execute(sql)
			Session("priAttachFileNames").RemoveAll
			Session("priAttachFileSizes").RemoveAll
			do while not rs.EOF
				if isnull(rs("priMsgAttachName")) then
					Session("priAttachFileNames").Add cstr(rs("priAttachID")), "Unkown"
				else
					Session("priAttachFileNames").Add cstr(rs("priAttachID")), cstr(rs("priMsgAttachName"))
				end if

				if isnull(rs("priMsgAttachSize")) then
					Session("priAttachFileSizes").Add cstr(rs("priAttachID")), "0"
				else
					Session("priAttachFileSizes").Add cstr(rs("priAttachID")), cstr(rs("priMsgAttachSize"))
				end if
				rs.MoveNext
			loop
		end if
	end if

	'保存附件
	Set objUp = Server.CreateObject("Persits.Upload.1")
	objUp.SetMaxSize mwMaxUploadSize, true
	on error resume next
	intCount = objUp.SaveToMemory
	Select case Err.number
	case 8:	'文件超过预设的长度
		strErrMessage = mwErrFileAcessMaxlength
	end select
	Err.Clear
	
	'将附件存入数据库

    '删除指定的附件
	if objUp.Form("DeleteFile") = "True" then
		intID = clng(objUp.Form("FileID"))
			if intID > 0 then
				sql = "delete from PrivateMessageAttach where priAttachID=" & intID
				cn.execute(sql)
				session("priAttachFileNames").Remove(cstr(intID))
				session("priAttachFileSizes").Remove(cstr(intID))
			end if
	else
		if objUp.Files.count > 0 then
			Set Rs=Server.CreateObject("ADODB.RecordSet")
			Rs.CursorLocation = adUseClient
			Rs.LockType = adLockOptimistic
			Rs.Open "Select * From PrivateMessageAttach Where 1=0", cn
			for each File in objUp.Files
				strFileName = File.ExtractFileName()
			    strFileName = File.ExtractFileName()
   				Rs.AddNew
   				Rs("priMsgAttachName") = strFileName
   				Rs("priMsgAttachSize") = File.Size
   				Rs("priMsgAttachContent") =  File.Binary
   				Rs.Update
   				intID = Rs("priAttachID")
				Session("priAttachFileNames").Add cstr(intID), strFileName
				Session("priAttachFileSizes").Add cstr(intID), cstr(File.Size)
			next
		end if
	end if
%>
<html>
<head>
<title>附件</title>
<meta NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../CssLib/List.css">
<Script Language="JavaScript" src="../../include/MSAlert.js"></Script>
<script language="javascript">
function showMessage(){
	var errmsg = "<%=strErrMessage%>";
	if (errmsg != "")
		MWalert(3, errmsg);		
}
var bclicked = false;

function DoUpload(){
	bclicked = true;
	Attach.submit();
}    

function DoDelete(){
	bclicked = true;
	if (Attach.FileList.selectedIndex != 0){
		Attach.DeleteFile.value = "True";
		Attach.FileID.value = Attach.FileList.options(Attach.FileList.selectedIndex).value;
		Attach.submit();
	}
}    

function DoClose(){
	bclicked = false;
	window.close();
}
</script>

<body topmargin="0" leftmargin="0" bottommargin="0" LANGUAGE="javascript" onunload="return window_onunload()" onload="showMessage();" bgcolor="#cce0f7">
<form name="Attach" method="post" target="_self" action="Attach.asp?Rnd=<%=intRnd %>" ENCTYPE="multipart/form-data">
<table bgColor="#6699cc" border="0" cellPadding="0" cellSpacing="0" class="table" height="25" width="450">
	<tbody>
		<tr bgColor="#6699cc">
			<td align="left" vAlign="top" width="15">
			</td>
			<td align="center" vAlign="middle" width="100%">
				<font class="title" color="#fafafa">附&nbsp;&nbsp;&nbsp;件</font>
			</td>
			<td align="left" vAlign="top" width="15">
			</td>
		</tr>
	</tbody>
</table>
<table bgColor="#9ba5ff" border="0" cellPadding="5" cellSpacing="0" class="table" height="18" width="450">
	<tbody>    
		<tr bgColor="#ffffff">
			<td align="middle" bgColor="#cce0f7" height="30" vAlign="middle" width="60">
				选择文件
			</td>
			<td align="left" bgColor="#cce0f7" height="30" width="200" vAlign="middle">
				<input type="File" name="AttachFile" class="liuyan" style="width=200">
			</td>
			<td align="left" bgColor="#cce0f7" height="30" width="60" vAlign="middle">
				<input class="btn" type="Button" name="btnSubmit" value="添加" 
				onmouseover="this.style.cursor='hand'" onclick="DoUpload();">
			</td>
			<td bgColor="#cce0f7" width="10"></td>
		</tr>
		<tr bgColor="#ffffff">
			<td align="middle" bgColor="#cce0f7" height="30" vAlign="middle" width="60">
				附件列表
			</td>
			<td align="left" bgColor="#cce0f7" height="30" width="250" vAlign="middle">
				<select id="FileList" name="FileList" class="sel" style="width=185">
					<option value>已经加入的附件:
<%
	for each key in session("priAttachFileNames").Keys
		Response.Write("<option value='" & key & "'>" & session("priAttachFileNames").Item(key) & "(" & session("priAttachFileSizes").Item(key) & "字节)")
	next
%>
				</select>
			</td>
			<td align="left" bgColor="#cce0f7" height="30" width="60" vAlign="middle">
				<input class="btn" type="button" name="btnDelete" value="删除" 
				onmouseover="this.style.cursor='hand'" onclick="DoDelete();">
			</td>
			<td bgColor="#cce0f7"></td>
		</tr>
</table>
<table bgColor="#cce0f7" border="0" cellPadding="0" cellSpacing="0" class="table" height="30" width="450">
	<tbody>
		<tr bgColor="#cce0f7" vAlign="middle">
			<td width="135"></td>
			<td align="middle" width="100">
				<input type="button" name="btnDone" value="完成" 
				onmouseover="this.style.cursor='hand'" onclick="DoClose();" 
				class="btn"> 
			</td>
			<td align="middle" vAlign="middle" width="100">
				<input class="btn" type="button" name="DelayConfirm" value="取消" 
				onmouseover="this.style.cursor='hand'" onclick="window.close();">
			</td>
			<td align="right"></td>
		</tr>
	</tbody>
</table>	
<input type="hidden" name="Done" value="False">
<input type="hidden" name="DeleteFile" value="False">
<input type="hidden" name="FileID" value>
</form>
<%
	Session("HoldFolder") = "True"
%>

<script ID="clientEventHandlersJS" LANGUAGE="javascript">
<!--
var file = "<%  for each key in session("priAttachFileNames").Keys
					Response.Write(session("priAttachFileNames").Item(key) & "(" & session("priAttachFileSizes").Item(key) & "字节)" & ";" )
				next %>"

function window_onunload()
{
	if (typeof(window.opener.window.attachments)!="object") return false;
	if (bclicked == true || window.opener.window.intRnd != <%=intRnd %>)
	{
		return false;
	}
	else
    {
		window.opener.window.attachments.innerText = file;
	}
}

//-->
</script>    
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -