PRU0561.jsp 4.99 KB
Newer Older
Thitichaipun Wutthisak committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
<%@page contentType="text/html; charset=UTF-8"%>
<%@page import="com.csc.library.entry.HelpEntry,com.csc.library.system.*,com.csc.library.utilities.*"%>
<%@ page import="com.csc.library.entry.*,com.csc.library.database.*,com.csc.library.session.*"  %>
<%@page import="java.util.*,java.net.*,java.io.*,com.csc.upload.*"%>
<jsp:useBean id="hmul" class="com.csc.upload.HttpMultiPartParser" scope="page"/>
<jsp:useBean id="PRU0561" class="com.csc.library.system.Task" scope="page"/>
<%

	PRU0561.setChannel(request,response);
	PRU0561.checkProfile();
	UProfile u=PRU0561.getUProfile();

 	InitialEnvironment en = new InitialEnvironment("GLOBAL");
	String reffilePath=en.getValue("PERSONAL_UPLOAD-dir");

	String tempdir = ".";

	request.setAttribute("dir", request.getParameter("dir"));
	String browser_name = request.getRequestURI();
	CheckNull chk =new CheckNull();

%>

<%
    session.setAttribute("finishUpload","false");
	if ((request.getContentType()!=null)&&(request.getContentType().toLowerCase().startsWith("multipart"))){
		response.setContentType("text/html");
		try{
			int bstart = request.getContentType().lastIndexOf("oundary=");
			String bound = request.getContentType().substring(bstart+8);
			Hashtable ht = hmul.processData(request.getInputStream(), bound, tempdir);
        			hmul.uploadFiles(ht);		
			FileInfo fi = (FileInfo)ht.get("myFile");
			File f = fi.file;
			session.setAttribute("empPic","./UPLOAD/"+f.getName());
			session.setAttribute("finishUpload","true");
		}
		catch (Exception e){ }
	}
%>

<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../CSS/TISCO.css" rel="stylesheet" type="text/css">
<link href="../CSS/MENU.css" rel="stylesheet" type="text/css">
<script  language="JavaScript" src="../JS/SCREEN.js"></script>
<script src="../JS/VIEWCALENDAR.js"></script>
<script language='javascript'>setLang('<%=u.get("lang")%>');</script>
<script language="JavaScript" >
<!--
function checktype()
{
	var stdstr="";
	with(document.cscform)
	{
		if(myFile.value.length>0)
		{
			setFileName(); 
		} else if (myFile.value.length==0)
			alert("กรุณาเลือกไฟล์ก่อน");
	}
}

function setFileName(){
	var file1 = document.cscform.myFile.value;
	var  reffileName="";
	if(file1.length>0&&checkFilename(file1)){ 
		reffileName=checkFilename(file1);
		window.opener.document.cscform.__atfile.value=reffileName;
		//window.opener.document.cscform.employeePic.src="./UPLOAD/"+reffileName;
		}
	document.cscform.submit();
}

function checkFilename(obj){
	var stdstr="";
		if(obj.length>0){
			stdstr=obj.substring(obj.lastIndexOf("\\")+1,obj.length);
		}
		return stdstr;
}

function  uploadfile(){
	checktype();
	//document.cscform.submit();
}

<!--

//-->

function closeUpload(){
     var flag ="<%=session.getAttribute("finishUpload")%>";
	 if(flag=="true"){
		setTimer();
	 }
}

function closePage(){
	    // window.opener.document.cscform.employeePic.src="<%=session.getAttribute("empPic")%>";
	     window.close();
}
function setTimer(){
	setTimeout("closePage()",5000);
}

</script>

</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" >
<form  name="cscform"  enctype="multipart/form-data"  method="POST">
			

<input  type="hidden" name="__cmd"  value=""> 
			<input type="hidden" name="__screen" value="PRU0561"> 
			<input type="hidden" name="__companyid" value="<%=u.get("companyid")%>"> 
			<input type="hidden" name="__language" value ="<%=u.get("lang")%>"> 

  <div align="center">

  	<br>
  	<br>
  	<br>	
	<div align="center">
 	<table  cellpadding="0"  cellspacing="0">
    <tr > 
    	<td  class="header">PRU0561,&nbsp;<script language="javascript">swapLang("File Insertion Page");</script>&nbsp;</td>
   	</tr>
    <tr > 
    	<td  colspan="2">
			<table width="630" border="0">
            <tr> 
              	<td colspan="3"><input type="hidden" name="dir" value="<%=reffilePath%>">
           	    <input type="hidden"name="__screen"  value="upload"></td>
            </tr>
            <tr>
              <td width="102" ><div align="right"><script language="javascript">swapLang("Attach file");</script></div></td>
              <td width="346">&nbsp;
              <input type="file" name="myFile" ></td>
              <td width="108">&nbsp;</td>
            </tr>
	   <tr> 
             	<td colspan="3">&nbsp;</td>
            </tr>
            <tr>
              <td colspan="3"><div align="center"><a href="javascript:uploadfile();"><img src="../IMAGES/BUTTON/UPLOAD.gif" border="0"></a></div></td>
            </tr>
	  <tr> 
             	<td colspan="3" align="center">Please wait for a moment while the file is uploaded.</td>
            </tr>
	  <tr> 
             	<td colspan="3" align="center">This window will automatically closed after the file is finishing uploaded.</td>
            </tr>
	  <tr>
		<td colspan="3">&nbsp;</td>
            </tr>
      		</table> 
		</td>
   	</tr>
    <tr> 
    	<td  class="bottom"></td>
  	</tr>	  
    </table>
  </div>
</form>
<script language="javascript">closeUpload();</script>
</body>
</html>