form里面有个select,encType="multipart/form-data" POST提交,其中还有个file在里面,主要是要上传图片,select里面是要上传到的文件夹的ID,如何获取这个值?
使用smartUpload上传的,图片上传正常,就是不能得到那个select的值,写数据库没法写进去

解决方案 »

  1.   

    smartUpload没用过,不过好像smartUpload重写了request方法,
    我一直用commonfileuplaod
      

  2.   

    SmartUpload mySmartUpload = new SmartUpload();
    String other=mySmartUpload.getRequest().getParameter("other");  //other为你的select的id
      

  3.   

    我以前做过,把代码贴出来共享:
    具体如下:提交:
       function uploadcrl(){
       if(form1.files.value==""){
       alert("请选择要上传的CRL文件");
       return false;
       }
       form1.encoding = "MULTIPART/FORM-DATA";
       form1.action="./uploadCRLAction.do";
       form1.submit();
      }
    后台处理:
    UploadCRLForm form = (UploadCRLForm) actionForm;
    FormFile file = form.getFiles();
    String filepath = System.getProperty("user.dir") + "/" + "TEMPCRL.crl";
    ShowCRLForm crlForm = new ShowCRLForm();
    String crlFileContentType = file.getContentType();
     try {
              InputStream stream = file.getInputStream();//把文件读入
              OutputStream bos = new FileOutputStream(filepath );
                  //建立一个上传文件的输出流,将上传文件存入web应用的根目录。
              //System.out.println(filePath+"/"+file.getFileName());
              int bytesRead = 0;
              byte[] buffer = new byte[8192];
              while ( (bytesRead = stream.read(buffer, 0, 8192)) != -1) {
                bos.write(buffer, 0, bytesRead);//将文件写入服务器
              }
              bos.close();
              stream.close();
            }catch(Exception e){
             e.printStackTrace();
            } 
      

  4.   

    LZ用的什么框架上传的
    encType="multipart/form-data" 必须去判断是FILE还是STRING类型的表单,做不同的处理.
      

  5.   

    这个可以用,不过在upload();方法后才行
      

  6.   

    看看这个
    使用jspsmartupload解决enctype引起的无法同时上传文件和接值的问题