<%@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="upload" class="com.csc.library.system.Task" scope="page"/> <jsp:useBean id="hmul" class="com.csc.upload.HttpMultiPartParser" scope="page"/> <% upload.setChannel(request,response); upload.checkProfile(); UProfile u=upload.getUProfile(); InitialEnvironment en = new InitialEnvironment("GLOBAL"); // String picturePath=en.getValue("dirroom-dir"); String tempdir = "."; request.setAttribute("dir", request.getParameter("dir")); //out.print("//-----//"+request.getParameter("dir")); String browser_name = request.getRequestURI(); //แก้ String flag = request.getParameter("flag"); %> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link href="../CSS/SIAMHR.css" rel="stylesheet" type="text/css"> <link href="../CSS/TISCO.css" rel="stylesheet" type="text/css"> <script type='text/javascript' src='../JS/SCREEN.js'></script> <script language='javascript'>setLang('<%=upload.getUProfile().get("lang")%>');</script> <script language="JavaScript" > <!-- function checktype(){ var stdstr=""; var pathPict=""; //alert("checktype"); with(document.cscform){ dir.value=window.opener.cscform.__picturepath.value; if(myFile.value.length>0){ stdstr=myFile.value.substring(myFile.value.lastIndexOf("\\")+1,myFile.value.length); if((stdstr.indexOf(".gif")>-1)||(stdstr.indexOf(".jpg")>-1)||(stdstr.indexOf(".JPG")>-1)||(stdstr.indexOf(".jpeg")>-1)||(stdstr.indexOf(".JPEG")>-1)||(stdstr.indexOf(".GIF")>-1)){ filename.value = stdstr; window.opener.document.cscform.__photo.value=stdstr; pathPict = "./IMAGES/"+window.opener.document.cscform.__folderpath.value+"/"+stdstr; //alert(pathPict); window.opener.document.cscform.employeePic.src=pathPict; //window.opener.document.cscform.employeePic.src="./IMAGES/"+window.opener.document.cscform.__folderpath.value+"/"+stdstr; //แก้ //action = "UPLOAD.jsp?flag=null"; action = "UPLOAD.jsp"; //alert("Yeh!!!"); //window.opener.document.cscform.employeePic.refresh(); //window.opener.document.cscform.employeePic.src="./IMAGES/"+window.opener.document.cscform.__folderpath.value+"/"+stdstr; //alert("Yeh!!!"); submit(); setTimeout("closePage()",5000); }else{ // alert("กรุณาเลือกไฟล์ รูปภาำพเท่านั้น ครับ"); alert(swap2String('Please choose only jpg or gif or jpeg picture file')); } } } } function chkLoad(){ with(document.cscform){ var emppic ="./IMAGES/"+window.opener.document.cscform.__folderpath.value+"/"+window.opener.document.cscform.__photo.value; //alert("EmpPict = "+emppic); //แก้ if(<%=flag%>==null){ window.opener.document.cscform.employeePic.src=emppic; window.opener.document.cscform.__pathfile.value = emppic; //alert(swap2String('Please_wait_until_page_be_closed')); setTimeout("closePage()",5000); } } } function closePage(){ var emppic ="./IMAGES/"+window.opener.document.cscform.__folderpath.value+"/"+window.opener.document.cscform.__photo.value; window.opener.document.cscform.employeePic.src=emppic; window.close(); } //--> </script> </head> <!--body onLoad="chkLoad();"--> <body> <table width="400" border="0" align="center" cellpadding="0" cellspacing="0"> <!--table width="100%" border="0" cellspacing="0" cellpadding="0"--> <tr> <td> <table align="center"cellpadding="0" cellspacing="0" class="maxsize"> <tr> <td class="header" colspan="2"></td> </tr> <form name="cscform" enctype="multipart/form-data" method="post"> <tr> <td> <div align="right"> <font color="#990000"> <script language="javascript">swapLang('Select picture');</script>::</font> <input type="hidden"name="__screen" value="upload"> <input type="hidden" name="dir" value=""> <input type ="hidden" name="filename" value="111111111"> </div> </td> <td valign="top" width="79%"><input type="file" name="myFile"> </td> </tr> <tr> <td align="right">.jpg , .gif <script language="JavaScript">swapLang('Only');</script> </td> <td><input type="Button" name="Submit" value="OK" onClick="checktype();"></td> </tr> <tr><td colspan="2"/></tr> <tr> <td colspan="2" align="center"> <script language="javascript">swapLang('Please wait for a moment while the picture is uploaded');</script> <br> <script language="javascript">swapLang('automatically closed after the picture is finishing uploaded');</script> </td> </tr> </form> <tr> <td colspan="2"> <% 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("empPicname",f.getName()); } catch (Exception e){ } } %> </td> </tr> </table> </td> </tr> </table> <script language="javascript">chkLoad();</script> </body> </html>