javax.servlet.ServletException: File can't be saved (1120).
com.jspsmart.upload.SmartUploadException: File can't be saved (1120).<jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload"/> request.setCharacterEncoding("GB2312");
mySmartUpload.initialize(pageContext);
mySmartUpload.upload(); String num=(String)session.getValue("number");
String school=(String)session.getValue("school");
String oldpath=(String)session.getValue("oldpath");
session.removeValue("oldpath");
String saveadd="c:/paper/2003/"+school+"/"+num;com.jspsmart.upload.File myFile=mySmartUpload.getFiles().getFile(0);
if (!myFile.isMissing()) {
java.io.File oldFile=new java.io.File(oldpath);
oldFile.delete();
java.io.File fileDir;
String path; if((saveadd!=null)&&(saveadd.length()>0)){
     String[] pathArray=saveadd.split("/");
     boolean[] resultArray=new boolean[pathArray.length-1];
     if(pathArray.length>=2){
         path=pathArray[0]+"/"+pathArray[1];
         fileDir = new java.io.File(path);  
        if(!fileDir.exists())
           resultArray[0]=fileDir.mkdir();  
        for(int i=2;i<pathArray.length;i++){
           path=path+"/"+pathArray[i];
           fileDir=new java.io.File(path);
           if(!fileDir.exists())
              resultArray[i-1]=fileDir.mkdir();  
        }
       }
     }
myFile.saveAs(saveadd+"/"+myFile.getFileName());
saveadd=saveadd+"/"+myFile.getFileName();
}
else
{saveadd=oldpath;}

解决方案 »

  1.   

    saveadd我输出了,没有错误啊
    出现不能保存这个错误的可能性有几种?
      

  2.   

    文件路径的问题! 你这个文件路径不存在呀! 你要先创建目录,然后才能把文件传到这个目录呀!..............................
    java.io.File myFilePath=new java.io.File(saveadd+"/");//创建目录
    if(!myFilePath.exists()) { myFilePath.mkdirs(); }myFile.saveAs(saveadd+"/"+myFile.getFileName());...............................
      

  3.   

    jspSmartUpload上传下载全攻略http://www.tongyi.net/article/20031015/200310153755.shtml