网站地址:
http://www.blogjava.net/hijackwust/archive/2007/08/22/138598.html
自己写的:批量图片上传
发送页:sample01.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<center>
<form action="sample01.jsp" method="post" ENCTYPE="multipart/form-data">
上传的名字:<input type="text" name="name"><br>
<input type="file" name="pic"> <br>上传的名字:<input type="text" name="name1"><br>
<input type="file" name="pic"> <br>
<input type="submit" value="上传">
</form>
</center>
</body>
<!--
</html>
<form action="sample01.jsp" method="post" ENCTYPE="multipart/form-data">
选择要上传的图片:
<input type="file" name="pic">
<input type="submit" value="上传">
</form>
-->
========================================
接受页:
<%@ page language="java" contentType="text/html"
pageEncoding="utf-8"%>
<%@page import="org.lxh.smart.SmartUpload"%>
<html>
<head>
<title>Test first picsmartupdate</title>
</head>
<body>
<jsp:useBean id="pic" scope="page" class="org.lxh.smart.SmartUpload"></jsp:useBean>
<%
pic.initialize(pageContext);
pic.upload();
// pic.save("c://jack");
String ext=pic.getFiles().getFile(0).getFileExt();
String ext1=pic.getFiles().getFile(1).getFileExt(); %>
<%
String name=pic.getRequest().getParameter("name");
String name1=pic.getRequest().getParameter("name1");
%>
<%
pic.getFiles().getFile(0).saveAs("c://jack/"+name+"."+ext);
pic.getFiles().getFile(1).saveAs("c://jack/"+name1+"."+ext1);
%></body>
</html>
=============================================
上面的代码也可以用两个<jsp:UseBean>接受
<input type="file" name="pic">
<input type="file" name="pic1">
-----------------------------------------------------------------
<jsp:useBean id="pic" scope="page" class="org.lxh.smart.SmartUpload"></jsp:useBean>
<jsp:useBean id="pic1" scope="page" class="org.lxh.smart.SmartUpload"></jsp:useBean>
效果是一样。