collection 사용한 버전 : https://dev-eunse.tistory.com/177
⚡ part만 이용하여 multiple을 저장(collection 사용 X)
<body> <form id="frm" enctype="multipart/form-data"> 첨부파일 : <input type="file" name="mfile" multiple="multiple"><br><br> <input type="button" value="전송" onclick="update()"> </form> </body> <script> function update(){ frm.method = "post"; frm.action = "./jsp16.do"; frm.submit(); } </script>
package shop; @MultipartConfig( fileSizeThreshold = 1024*1024*2, maxFileSize = 1024*1024*5, maxRequestSize = 1024*1024*100 ) public class jsp16 extends HttpServlet { private static final long serialVersionUID = 1L; protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String url = request.getServletContext().getRealPath("/upload/"); for(Part file : request.getParts()) { String filename = file.getSubmittedFileName(); file.write(url + filename); } System.out.println("파일전송 완료"); } }
'CLASS > JSP' 카테고리의 다른 글
do에서 jsp로 include하여 여러개의 페이지를 로드할 수 있음 (0) | 2024.07.02 |
---|---|
#4-5 / 상품 리뷰 등록,list,삭제,수정 (0) | 2024.06.28 |
#4-3 / 파일 업로드(stream) (0) | 2024.06.27 |
#4-2 / 첨부파일 여러개 업로드시 사용법 (0) | 2024.06.27 |
#4-1 / 상품 등록 및 삭제 (0) | 2024.06.27 |