해당 폴더 마우스 오른쪽 클릭
읽기전용 해제
part.write에 업로드 파일 경로 써주기
package configure;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
@MultipartConfig(
//파일 업로드 기능 처리 시 사용되는 어노테이션속성
fileSizeThreshold = 1024*1024*1, //1mb(파일 업로드시 사용되는 메모리 임시크기 용량)
maxFileSize = 1024*1024 *2, //2mb(업로드 파일 최대 크기값)
maxRequestSize = 1024*1024 *2 //2mb(전송에 따른 최대 크기값)
)
public class fileuploadok extends HttpServlet {
private static final long serialVersionUID = 1L;
public fileuploadok() {
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=utf-8");
Part filepart = request.getPart("file");
String filename=filepart.getSubmittedFileName();
//System.out.println(filename);
for(Part part:request.getParts()){
part.write("C:\\myhome\\review_nc\\src\\main\\webapp\\upload\\"+filename);
}
response.getWriter().print("ok");
//System.out.println(filepart);
}
}
728x90
'ETC > 개발지식' 카테고리의 다른 글
[제작순서] 게시판, 회원가입, 공지사항, 갤러리보드, 상품등록 (0) | 2022.08.08 |
---|---|
이클립스 파일 Export 할 때 주의할 점 (0) | 2022.08.04 |
MySQL 백업하기 / cafe24 데이터베이스에 강제로 데이터 베이스 넣기 (0) | 2022.08.03 |
ip주소 바꾸기 (0) | 2022.08.01 |
이클립스 테마 플러그인 추천 (0) | 2022.07.19 |
댓글