如何解决多个上传框同名的问题(注意不是上传文件的同名) ,类似下面的 :
<input type= "file " name = "ouhn ">
<input type= "file " name = "ouhn ">
<input type= "file " name = "ouhn ">
……………………
<input type= "file " name = "ouhncom ">
<input type= "file " name = "ouhncom ">
<input type= "file " name = "ouhncom ">
……………………
互联网都快被我翻遍了, 还是没找到理想的解决方法 !!!
难道那些写组件的都没意识到这个问题吗? 纳闷 ……
继续求助高手, 此帖为第4个100 分,共500分,一分不会少。
先谢谢各位……
------解决方案--------------------
lz的问题是:上传框同名无法上传吗?
我试了一下没有问题,我使用的是commons-fileupload-1.0组件,同时上传6个文件。
******************* test.jsp ********************
<%@page contentType= "text/html; charset=GBK "%>
<html>
<head>
<title> jsp1 </title>
</head>
<body bgcolor= "#ffffff ">
<form action= "Servlet " method= "post " enctype= "multipart/form-data ">
<input type= "file " name= "a ">
<br>
<input type= "file " name= "a ">
<br>
<input type= "file " name= "a ">
<br>
<hr>
<input type= "file " name= "b ">
<br>
<input type= "file " name= "b ">
<br>
<input type= "file " name= "b ">
<br>
<input type= "submit " name= "Submit " value= "upload " />
</form>
</body>
</html>
******************** Servlet.java **********************
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import org.apache.commons.fileupload.*;
import java.util.Date;
import java.text.SimpleDateFormat;
public class Servlet extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=GBK ";
//Initialize global variables
public void init() throws ServletException {
}
//Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
//获得服务器应用程序所在的绝对路径
String realPath = this.getServletContext().getRealPath(this.
getServletName());
realPath = realPath.substring(0, realPath.lastIndexOf( "\\ "));
String uploadPath = realPath + "\\upload\\ "; // 用于存放上传文件的目录
String tempPath = realPath + "\\upload\\temp "; // 用于存放临时文件的目录
//创建目录
File uploadPathDir = new File(uploadPath);
if (!uploadPathDir.exists()) {
uploadPathDir.mkdirs();
}
File tempPathDir = new File(tempPath);
if (!tempPathDir.exists()) {
tempPathDir.mkdirs();
}