제일 먼저 

http://www.servlets.com/cos/ 에서 cos-26Dec2008.zip 파일을 다운 받아서


c : 아파치 폴더에 있는 lib 에 압축을 풀어서 넣는다.



form6.html


<!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>조으디조으디조으디  간나새뀌</title>

</head>

<body>


<form action="form6.jsp" method="post" enctype="multipart/form-data">


파일 : <input type = "file" name="file"><br>

설명 : <input type = "text" name="desc"><br>

<input type="submit" value="업로드(해킹)">

<input type="reset" value="취소">


</form>

</body>

</html>






form6.jsp

<%@ page language="java" contentType="text/html;charset=EUC-KR"

pageEncoding="EUC-KR"%>

<%@ page import="com.oreilly.servlet.MultipartRequest,

com.oreilly.servlet.multipart.DefaultFileRenamePolicy,java.io.File" %>


<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">

<title> 업로드가 완료 되었다 조으디 ㅋㅋ</title>

</head>

<body>

<% 

String savePath = application.getRealPath("/upload");

int sizeLimit = 5*1024*1024;

MultipartRequest mr = new MultipartRequest(request,savePath,sizeLimit,"euc-kr",new

DefaultFileRenamePolicy());


File file = mr.getFile("file");

String fileName = file.getName();

long fileSize = file.length();

if(fileName == null){

out.println("파일 업로드 실패");

}else{

out.println(savePath + "<br/>");

out.println("파일명 : " + fileName + "<br/>");

out.println("파일크기 : " + fileSize + "<br/>");

out.println("설명 : " + mr.getParameter("desc") + "<br/>");

}

%>


</body>

</html>

블로그 이미지

김진리

,