你的接收代碼問題,附上我的
DiskFileUpload upload = new DiskFileUpload();
List items = upload.parseRequest(request);
Iterator iter = items.iterator();
FileItem item;
while(iter.hasNext()){
item = (FileItem) iter.next();
if (item.isFormField()){
;
}else{
String itemName = item.getName();
file_name = itemName.substring(itemName.lastIndexOf("\\")+1);
file_name = "D:\\ebank\\ebank\\upload\\" + file_name;
File newFile = new File(file_name);
if (newFile.exists())
error = "";
else{
newFile.createNewFile();
item.write(newFile);
}
}
}

解决方案 »

  1.   

    when uploading, all of the files are being uploaded!you should save the files first then delete some of them!
      

  2.   

    解决了,我之前是将捕获异常的代码写在了循环外层,所以不按顺序时出现异常就会跳出循环:
    try{
       while(iter.hasNext()){
                ....
             }
    }
    catch(Exception e){}
    现在改为:
    while(iter.hasNext()){
        try{
             ...
            }
         catch(..){}
      }
    就好用了,哈哈!!!
      

  3.   

    用JSPSMARTUPLOAD不错的,现在放分怎么都接不到啊??
      

  4.   

    to yyqllxh2004(潇一郎):
    我曾经用过JSPSMARTUPLOAD,但在初始化时就停止不前了,好像是程序就停在那里了,也不抱错,
    不知道是怎么回事。
      

  5.   

    用JSPSMARTUPLOAD:
    http://community.csdn.net/Expert/topic/3212/3212206.xml?temp=.7760126
      

  6.   

    我从网上找了一个例子,但不知为什么总会抛出异常。代码如下:
    提交页面:
    <html>
    <head>
    <title>文件上传演示</title>
    </head>
    <body bgcolor="#FFFFFF"text="#000000" leftmargin="0"topmargin="40"marginwidth="0" marginheight="0">
    <center>
    <h1>文件上传演示</h1>
    <form name="uploadform"method="POST" action="upload.jsp"ENCTYPE="multipart/form-data">
     <table border="1"width="450"cellpadding="4" cellspacing="2"bordercolor="#9BD7FF">
     <tr><td width="100%"colspan="2">
     文件1:<input name="file1"size="40"type="file">
     </td></tr>
     <tr><td width="100%"colspan="2">
     文件2:<input name="file2"size="40"type="file">
     </td></tr>
     <tr><td width="100%"colspan="2">
     文件3:<input name="file3"size="40"type="file">
     </td></tr>
     </table>
     <br/><br/>
     <table>
     <tr><td align="center"><input name="upload" type="submit"value="开始上传"/></td></tr>
     </table>
    </form>
    </center>
    </body>
    </html>
      

  7.   

    (续上)upload.jsp:<%
    /**
     * 演示文件上传的处理
     * @author <a href="mailto:[email protected]">Winter Lau</a>
     * @version $Id: save.jsp,v 1.00 2003/03/01 10:10:15
     */
    %>
    <%@ page language="java"contentType="text/html;charset=GBK"%>
    <%@ page import="java.util.*"%>
    <%@ page import="org.apache.commons.fileupload.*"%>
    <html>
    <head>
    <title>保存上传文件</title>
    </head>
    <%
     String msg = "";
     FileUpload fu = new FileUpload();
     // 设置允许用户上传文件大小,单位:字节
     fu.setSizeMax(10000000);
     // maximum size that will be stored in memory?
     // 设置最多只允许在内存中存储的数据,单位:字节
     fu.setSizeThreshold(4096);
     // 设置一旦文件大小超过getSizeThreshold()的值时数据存放在硬盘的目录
     fu.setRepositoryPath("C:\\TEMP");
     //开始读取上传信息
     List fileItems = fu.parseRequest(request);
    %>
    <body bgcolor="#FFFFFF"text="#000000" leftmargin="0"topmargin="40"marginwidth="0" marginheight="0">
    <font size="6"color="blue">文件列表:</font>
    <center>
    <table cellpadding=0 cellspacing=1 border=1 width="100%">
    <tr>
    <td bgcolor="#008080">文件名</td>
    <td bgcolor="#008080">大小</td>
    </tr>
    <%
     // 依次处理每个上传的文件 Iterator iter = fileItems.iterator();
    while (iter.hasNext()) {
    FileItem item = (FileItem) iter.next();
    //忽略其他不是文件域的所有表单信息
    if (!item.isFormField()) {
    String name = item.getName();
    long size = item.getSize();
    if((name==null||name.equals("")) && size==0)
    continue;
    %>
    <tr>
    <td><%=item.getName()%></td>
    <td><%=item.getSize()%></td>
    </tr>
    <%
       //保存上传的文件到指定的目录
       try{name = name.replace(':','_');
       name = name.replace('\\','_');
       item.write("F:\\"+ name);}catch(Exception e){out.println(e);}
      }
     }
    %>
    </table><br/><br/>
    <a href="ulface.htm">返回上传页面</a>
    </center>
    </body>
    </html>bug:有些图片可以上传(格式是.gif),试了很多次,jpg图片始终不能上载,对于gif图片
    有的可以上载,有的不行。对commons-fileupload上传的过程也不太明白。高手指点一二。
      

  8.   

    高手一个问题,在用multipart/form-data提交时,在下一个页怎么取如注释文本域的内容,我取得的都是NULL
      

  9.   

    to 落叶:你可以参考这篇文章
    http://www.javaworld.com.tw/confluence/pages/viewpage.action?pageId=720