[TIL] 2020.07.23_TIL-200723
To-Do
- [복습] 세션 복습
세션 개념
파일 저장할 테이블 생성
create table t_board_file(
no number(5) primary key
, board_no number(5) not null
, file_ori_name varchar2(300)
, file_save_name varchar2(300)
, file_size number(10)
, constraint t_board_file_board_no_fk foreign key(board_no)
references t_board(no) on delete cascade -- t_board(no) 지워지면 외래키로 가지고 있는 데이터도 연쇄적으로 삭제
);
create sequence seq_t_board_file_no nocache;
fileUpload.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h2>파일 업로드 테스트</h2>
<form action="uploadInfo.jsp" method="post"
enctype="multipart/form-data">
ID : <input type="text" name="id"><br>
파일 : <input type="file" name="uploadfile"><br>
<input type="submit" value="제출">
</form>
</body>
</html>
uploadInfo.jsp
<%@page import="java.io.InputStreamReader"%>
<%@page import="java.io.BufferedReader"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
InputStreamReader isr = new InputStreamReader(request.getInputStream(), "utf-8");
BufferedReader br = new BufferedReader(isr);
while(true) {
String buf = br.readLine();
if(buf == null) break;
out.print(buf + "<br>");
}
%>
</body>
</html>
댓글남기기