怎么样上传文件点上传时解析为二进制流,麻烦写一下关键的代码!

解决方案 »

  1.   

    Apache Commons FileUpload 组件,几行代码就能搞定了到这里去看一下他的用户指南就可以了:http://commons.apache.org/fileupload/
      

  2.   

    if (name != null && !name.equals("") && size != 0) {
                    String filePath = System.currentTimeMillis() + "_" + name;
                    item.write(new File(uploadDir, filePath));                Upload upload = new Upload();//这一行报错请问这里应该new什么?
                    upload.setFileName(name);
                    upload.setFilePath("upload/" + filePath);
                    upload.setFileSize(size);
                    upload.setAddDate(new Date());                List.add(upload);
                }
      

  3.   

    if (name != null && !name.equals("") && size != 0) {
                    String filePath = System.currentTimeMillis() + "_" + name;
                    item.write(new File(uploadDir, filePath));                Upload upload = new Upload();//这一行报错请问这里应该new什么?
                    upload.setFileName(name);
                    upload.setFilePath("upload/" + filePath);
                    upload.setFileSize(size);
                    upload.setAddDate(new Date());                List.add(upload);
                }
      

  4.   


    没用过噢不能new,找找看有没有getInstance()方法或者其他带参数的构造方法