我也帖个前几天写的上传:
<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.oreilly.servlet.MultipartRequest" %>
<%!
String saveDirectory = "E:\\resin210\\doc\\cover\\";
int maxPostSize = 1 * 1024 * 1024 ;
String FileName = null;
%>
<%
MultipartRequest multi = new MultipartRequest(request , saveDirectory , maxPostSize );
%>
<%
Enumeration filesname = multi.getFileNames();
while (filesname.hasMoreElements())
{
String name = (String)filesname.nextElement();
FileName = multi.getFilesystemName(name);
File f = multi.getFile(name);
String ContentType = multi.getContentType(name);
if (FileName != null)
{
%>
上传成功! 文件名称为:<%= FileName %>
文件类型为:<%= ContentType %>
返回
<%
}
}
%>