日期:2014-05-16  浏览次数:20461 次

jsmartupload一个让人纠结的问题?
Files' name is invalid or does not exist (1205).
相信有很多人遇到这个问题
我在网上查了下,绝大数的回答是
在form表单中添加enctype="multipart/form-data" 
但是我改了依旧还是这个问题:
大家看看代码 到底哪出错了哦已经搞了半天了

这个是上传的首页面
HTML code

<%@ page language="java"  pageEncoding="UTF-8"%>
<html>
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>上传图片</title>    
    <script type="text/javascript" src="scripts/jquery.js"></script>
    <link href="styles/default.css" rel="stylesheet" type="text/css" />
  </head>
   <script type="text/javascript">
       function comm(){
           var spell = document.form1.spell.value;
           document.form1.action="flowManage.m?m=doupload&spell="+spell;
           document.form1.submit();
       }
   </script>
  <body>
  <form action="" name="form1" method="post" enctype="multipart/form-data">
    <input type="hidden" name="spell" value="${officelocation.spell}"/>
    <table    width="75%" border="1" align="center">
        <tr>
            <td>
                <div align="center">
                    <input type="file" name="" size="30">
                </div>
            </td>
        </tr>
        <tr>
            <td><input type="submit" name="" value="提交" onclick="comm()"/></td>
        </tr>
    </table>
  </form>
  </body>
</html>



这个是上传用到的smartupload页面
HTML code

<%@ page language="java"  pageEncoding="UTF-8"%>
<%@page import="com.jspsmart.upload.SmartUpload"%>
<%@page import="com.jspsmart.upload.File"%>
<%@page import="com.jspsmart.upload.Files;"%>
<html>
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>文件处理页面</title>    
    <script type="text/javascript" src="scripts/jquery.js"></script>
    <script type="text/javascript" src="scripts/validator.js"></script>
    <link href="styles/default.css" rel="stylesheet" type="text/css" />
  </head>
  
  <body>
      <%
          String spell = (String)request.getParameter("spell");
          SmartUpload su = new SmartUpload();//新建对象
          su.initialize(pageContext);//初始化
          //设置上传限制
          su.setMaxFileSize(10000);//限制每个上传的最大长度
          su.setTotalMaxFileSize(20000);//限制总上传数据长度
          su.setAllowedFilesList("jpg,JPG,JPEG,png");//限制上传的类型
          su.setDeniedFilesList("exe,bat,jsp,html,htm,,");//禁止上传的有拓展名,和没有拓展名的文件
          su.upload();
          int count = su.save("/flowimages");//保存到指定路径
          out.print(count+"个图片上传成功");
          Files files = su.getFiles();
          File file= files.getFile(0);
              //将文件另存为
          file.saveAs("/flowimages"+spell,su.SAVE_VIRTUAL);
       %>
  </body>
</html>



出现的错误:

java.lang.IllegalArgumentException: Files' name is invalid or does not exist (1205).
at com.jspsmart.upload.Files.getFile(Files.java:73)
at org.apache.jsp.TouchScreen.do_005fupload_jsp._jspSe