Turn from: http://blog.csdn.net/pharaohsprince/
Change it a little bit!
Upload.html
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en"
"Http://www.w3.org/TR/html4/loose.dtd" >
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> Untitled Document </title>
<body>
<!--enctype value is important, upload.jsp for processing uploaded jsp-->
<form name= "Form1" method= "Post" enctype= "Multipart/form-data" action= "upload.jsp" >
<p>
<input name= "file1" type= "File" >
</p>
<p>
<input name= "file2" type= "File" >
</p>
<p> <input name= "file3" type= "File" >
</p>
<p>
<input type= "Submit" name= "submit" value= "Upload" >
</p>
</form >
</body>
<% @page import= "java.io.*"%>
<% @page import= "java.util.*"%>
<% @page import= "Com.oreilly.servlet.MultipartRequest"%>
<% @page contenttype= "text/html; charset=gb2312 "%>
<%
File upload, save in C://upload
java/lang/string.java.html "target=" _blank ">
String savedirectory = "C://upload";
Maximum 5m per file, up to 3 files, so ...
int maxpostsize = 3 * 5 * 1024 * 1024;
Response is encoded as "gb2312", and the default filename conflict resolution strategy is used to implement the upload
Multipartrequest multi =
New Multipartrequest (Request, Savedirectory, Maxpostsize,
"gb2312");
Output feedback Information
Enumeration files = Multi.getfilenames ();
while (Files.hasmoreelements ()) {
SYSTEM.ERR.PRINTLN ("CCC");
String name = (string) files.nextelement ();
File f = multi.getfile (name);
if (f!=null) {
String fileName = multi.getfilesystemname (name);
String lastfilename= savedirectory+ "//" + fileName;
Out.println ("uploaded file:" +lastfilename);
Out.println ("}
}
%>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
upload.jsp