<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>File Upload</title>
</head>
<body>
<center>
<h2>File Upload</h2>
<form action="FileUploadProc.jsp" method="post" enctype="multipart/form-data">
<table>
<tr>
<td>작성자</td>
<td><input type="text" name="writer"></td>
</tr>
<tr>
<td>제목</td>
<td><input type="text" name="subject"></td>
</tr>
<tr>
<td>파일</td>
<td><input type="file" name="upload"></td>
</tr>
<tr >
<td></td>
</tr>
</table>
<input type="submit" value="send">
</form>
</center>
</body>
</html>
FileUploadProc.jsp
<%@page import="com.oreilly.servlet.multipart.DefaultFileRenamePolicy"%>
<%@page import="com.oreilly.servlet.MultipartRequest"%>
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>File Upload Procedure</title>
</head>
<body>
<%
String realfolder = "";
String saveFolder = "File";
String encType = "euc-kr";
int maxSize = 1024 * 1024 * 5;
ServletContext context = getServletContext();
realfolder = context.getRealPath(saveFolder);
out.println(realfolder);
try
{
MultipartRequest multi = new MultipartRequest(
request, realfolder, maxSize, encType,
new DefaultFileRenamePolicy());
}
catch(Exception e)
{
}
%>
</body>
</html>
result)
댓글 없음:
댓글 쓰기