
<%
/**********************************************************************************
	프로그램명		: write_file_upload.jsp
	프로그램설명	: 
	작 성 자			: 
	작 성 일			: 
	최신변경일		: 
***********************************************************************************/
%>
<%@ page contentType="text/html; charset=UTF-8"%>

<%@ page import="java.net.*"%>
<%@ page import="kr.co.kihyun.lang.Encoder"%>

<%@ include file="/totsys/common/inc/sec/secure.inc.jsp"%>

<%
try{
	/****** Parameter ******/
	String execMode = "";
	String svrFilename = "";
	String usrFilename = "";
	String boardGroupID = "";

	execMode = request.getParameter("execMode");
	svrFilename = Encoder.toJava(request.getParameter("svrFilename"));
	usrFilename = Encoder.toJava(request.getParameter("usrFilename"));
	boardGroupID = request.getParameter("boardGroupID");

	String chkExt="";
	if(execMode!="init"){
		chkExt=checkext(svrFilename,"");
		if(chkExt.equals("false")){
			execMode="error";
		}

		chkExt=checkext(usrFilename,"");
		if(chkExt.equals("false")){
			execMode="error";
		}
	}
%>
<html>
<head>
<META http-equiv="Content-Type"
	content="text/html; charset=UTF-8">
<link rel="stylesheet" href="/totsys/common/css/text.css"
	type="text/css">
<script src="/totsys/common/js/rollover.js"></script>
<script language="javascript">
	<!--  
		function checkVal() {
			var frm = document.upFrm

			if (frm.appendFile.value == ""){
				alert ('먼저 찾아보기 버튼을 눌러 이미지를 선택해주세요.');
				return;
			}else if(parent.num > 4){
				alert ('5개까지만 첨부 가능 합니다.');
				return;
			}
			frm.submit();
		}


		function exec(execMode){
			if(execMode == "up"){
				//파일 업로드 모드
				parent.checkFile('<%= svrFilename %>', '<%= usrFilename %>');					
				this.location='./write_file_upload.jsp?boardGroupID=<%= boardGroupID %>&execMode=init';

			}else if(execMode == "del"){
				//파일 삭제 모드
				alert("파일이 삭제 되었습니다.");

			}else if(execMode == "init"){
				//초기 실행 모드				
			}else if(execMode == "jump"){				
				this.location='./write_file_upload.jsp?boardGroupID=<%= boardGroupID %>&execMode=init';

			}else{
				alert("잘못된값이 입력되었습니다. 다시 시도 하여 주세요.");
				return;
			}
		}
		//-->
	</script>
</head>

<body style='' onload="exec('<%= execMode %>');">
<TABLE cellSpacing="0" cellPadding="0" width="100%" align="left"
	border="0">


	<tr>
		<td width="400">

		<table width="100%" cellSpacing="0" cellPadding="0">

			<tr>
				<td height="2"></td>
			</tr>

			<tr>
				<!-- form upFrm -->
				<form
					action='/servlet/kr.co.kihyun.beans.totsys.board.HttpAdmFileUpload'
					name='upFrm' enctype='multipart/form-data' method='post'><input
					type="hidden" name="boardGroupID" value="<%= boardGroupID %>">
				<td align="left"><input type=file style="width: 100%"
					name="appendFile" class="inputtxt"></td>
				<td width="83" nowrap align="center"><a href="#"><img
					src="/totsys/common/images/bt_file_append.gif"
					onClick="checkVal();" border="0" align="absmiddle"></a></td>
			</tr>
			<tr>
				<td><font
					style="font-family: 돋움; font-size: 12px; color: #666666; padding-top: 3px;"
					color=565656>&nbsp;&nbsp;- 관련자료 선택 후 추가버튼(파일당 5M, 5개까지)</font></td>
				<td width="83" nowrap align="center"><a href="#"><IMG
					src="/totsys/common/images/bt_file_del.gif" border="0"
					name='delBtn' value='삭제' onClick='parent.delFrm();'
					align="absmiddle"></a></td>
				</form>
			</tr>
		</table>


		</td>

		<td>


		<table width="100%" cellSpacing="0" cellPadding="0">
			<tr>
				<!-- form delFrm -->
				<form
					action='/servlet/kr.co.kihyun.beans.totsys.board.HttpAdmFileDelete'
					name='delFrm' method='post'><input type="hidden"
					name="boardGroupID" value="<%= boardGroupID %>" class=inputtxt>
				<td align="left" colspan="2"><select name='fileList'
					style="width: 100%" size=2 class="inputtxt">
					<option selected value="-1">-------------------------------
					관련자료 -------------------------------</option>
					<script>

								usrFilenameList = parent.usrFilenames.split(";", parent.num);
								svrFilenameList = parent.svrFilenames.split(";", parent.num);
								for (i=0; i<parent.num; i++){
									document.write ("<option value='" + svrFilenameList[i] + "'>" + usrFilenameList[i].substr(0, 20) + "</option>");
								}
							</script>
				</select></td>
				</form>
			</tr>
		</table>


		</td>
	</tr>








</table>
</body>
</html>
<%
}catch(Exception ex){
	ex.printStackTrace();
}
%>
