버튼을 누르면 업로드 파일 상자가 나타납니다

3024 단어 htmljsp
<!--          ,  IMPORT   DIV    -->
		<div id="upLoadForm" align="center" class="area" style="width:200 height:200 visibility:hidden">
		<form name="upform"  method="POST" enctype="multipart/form-data" target="myFrame"><!--target        IFRAME   ,     -->
         <input type ="file" name="file" id="file"/>
		 <input type="hidden" name="textDatasImport" value="tt"><!--   ,           -->
        <input type="button" value="  " onclick="handle('import')"/>
         </form>
		</div>

HTML에 숨겨진 DIV 삽입
//      
function openUploadWin() 
{ 
    if(!bSelected)
	 {
	window.alert("         !");
	return;
	 }
  upLoadForm.style.left=document.body.scrollLeft+document.body.clientWidth/2-100;
  upLoadForm.style.top=document.body.scrollTop+document.body.clientHeight/2-100;
  /*upLoadForm.innerHTML=" <form name="upform"  method="POST" enctype="multipart/form-data">"
  +"<input type ="file" name="file" id="file"/>"
  +"<input type="button" value="  " onclick="handle('import')"/>"
  +"</form>";
*/

 upLoadForm.style.visibility="visible";
  
} 

업로드 상자에 표시되는 JS 코드였습니다.
  document.upform.textDatasImport.value=value;//             
			init();
		   upLoadForm.style.visibility="hidden";
           document.upform.action="importFromExcel";
		   document.upform.submit();

업로드 단추를 누르고 코드를 실행하면 프론트 데스크톱의value를 upform의hidden 텍스트 상자 textDatasImport에 부여하고 백엔드에서 처리합니다
이 값을 얻는 방법
SMARTUPLOAD 사용하기
SmartUpload upload = new SmartUpload();
		try {
			upload.initialize(this.getServletConfig(), request, response);
			//          
			upload.setAllowedFilesList("doc,xls,");
			//          
			upload.setDeniedFilesList("exe,bat,jsp");
			//              
			upload.setMaxFileSize(1024 * 1024 * 20);
			//              
			
			//     
			upload.upload();

			StringBuffer fullFileName = null;//            (   )
			File suFile = upload.getFiles().getFile(0);
			fullFileName = new StringBuffer("data.xls");//         
			suFile.saveAs(fullFileName.toString(), SmartUpload.SAVE_PHYSICAL);

		} catch (Exception e) {
			e.printStackTrace();
			return;
		}
       //  FORM              
		Request req = upload.getRequest();
		String texts = (String) req.getParameter("textDatasImport"); //      

좋은 웹페이지 즐겨찾기