wms's Programming&Study

[JAVA] MultipartFile을 File로 변환 본문

Programming/JAVA

[JAVA] MultipartFile을 File로 변환

wms2275 2019. 10. 31. 15:43
function listDownload() {
	$("#fileUpload").attr("action", "/error/list/toExcel")
	$("#fileUpload").submit();
}
			<form id="fileUpload" method="post" enctype="multipart/form-data">
				<input type="text" id="filename1" name="filename1" readonly="readonly"/>
				<label for="uploadFile1" class="filebox_label">엑셀파일1</label>
				<input type="file" id="uploadFile1" name="uploadFile1" onchange="onChangeFile1()"/>
				
				<input type="text" id="filename2" name="filename2" readonly="readonly"/>
				<label for="uploadFile2" class="filebox_label">엑셀파일2</label>
				<input type="file" id="uploadFile2" name="uploadFile2" onchange="onChangeFile2()"/>
				
				<button type="button" onclick="listDownload()">엑셀 다운로드</button>
			</form>
	@RequestMapping(value="/error/list/toExcel")
	public void errorListLoad(HttpServletRequest request, HttpServletResponse response, 
			@RequestParam(value="uploadFile1") MultipartFile file1, @RequestParam(value="uploadFile2") MultipartFile filename2) throws FileNotFoundException {
	
			File convFile = new File(file1.getOriginalFilename());
			file1.transferTo(convFile);
            }