Web Application

파일 업로드

무르뇌 2022. 8. 11. 16:11

*파일업로드

1.jar 파일 다운로드

=> http://jakarta.apache.org 

 

The Jakarta Site - The Apache Jakarta™ Project -- Java Related Products

Founded in 1999, the Jakarta Project housed a diverse set of popular open source Java solutions. In 2005, as a part of creating a flatter Apache Software Foundation, Jakarta subprojects began to become full top-level Apache projects. This process has conti

jakarta.apache.org

2. WEB-INF - lib에 복사 (fileupload 및 io 두 개 다 복사해야 에러 안남)

3. 메뉴얼 체크

4. 브라우저 ---파일---> 서버 

=> 저장할 디렉토리를 생성. ex) c:\upload

5. uploadForm.jsp 생성

6. 파일업로드는 get방식이 아닌, post 방식이다 

why? -> get 방식은 쿼리형태 즉, string url로 전달되기 때문. 따라서 무조건 post 방식으로 전달해야한다.

 

코드:

<form action"서블릿" method="post" encType="multipart/form-data">

https://commons.apache.org/proper/commons-fileupload/index.html 참고할것