JSP/Servlet: Oreilly MultiPartRequest 檔案上傳

  • form.htm
<html> 
<head>
<title>檔案上傳</title>
<meta http-equiv="Content-Type"
content="text/html; charset=Big5">
</head>
<body>
<b>檔案上傳</b></font></p>

<form name="UploadForm"
enctype="multipart/form-data"
method="post" action="upload.jsp">
<input type="file" name="File1" size="20" maxlength="20">
<br>
<input type="file" name="File2" size="20" maxlength="20">
<br>
<input type="submit"value="上傳">
</form>

</body>
</html>
  
  
  
  
  • upload.jsp
<%@page import="com.oreilly.servlet.MultipartRequest" %> 
<%
String saveDirectory = "/home/caterpillar/files/";
// 限制上傳之檔案大小為 5 MB
int maxPostSize = 5 * 1024 * 1024 ;
MultipartRequest multi = new MultipartRequest(request ,
saveDirectory , maxPostSize, "MS950");
out.println("檔案上傳OK");
%>

你可能感兴趣的:(html,String,File,input,action,import)