如何检索通过<input type =“file”multiple =“”/>选择的两个文件的输入流

时间:2014-12-09 07:11:47

标签: java html5 groovy

我正在使用html5标签`

选择两个文件
<input type="file"  class="labelclass" id="files" style="border: 1px solid #7F9DB9;font-size: 22px
" multiple="multiple">
<input type="button" style="background-image: url(app/images/upload.jpg); width:257px;
    height:58px;border-radius:20px;"   onclick="startRead()">

ajax调用发送文件

function startRead()
{
      $.ajax({
        url: 'url?sessionid='+sessionid+'&modelNo='+
        $("#modelno").val()+'&packageName='+$("#packagename").val()+'&version='+$("#version").val()+'',
        data:{"file1":document.getElementById('files').files[0],"file2":document.getElementById('files').files[1]},
        contentType: 'application/exe',
        beforeSend: function (xhr) {
            xhr.setRequestHeader('Content-Disposition', document.getElementById('files').files[0].name);
        },
        processData: false,
        type: 'POST',
        success: function(data){
          alert(data);
        }
        ,error:function(data)
        {alert(data);
        }
    });
}

我想检索服务器上两个文件的输入流 服务器端代码是java或groovy 请帮我用bot happroaches检索inputream

1 个答案:

答案 0 :(得分:-1)

FormFile myFile = configForm.getTheFile();  
InputStream input=myFile.getInputStream();