1

여기 파일을 업로드하기 위해 jQuery-File-Upload를 사용하고 있습니다. 잘 작동하고 있습니다. 하지만 여기 파일은 우리가 파일을 선택하면 업로드, 나는 제출 버튼을 클릭 한 후 파일을 업로드해야합니다. 이 문제를 해결하는 방법을 알려주십시오. 다음 코드를 사용하고 있습니다.버튼을 클릭하는 동안 mvc에 jquery 파일 업로드

$('#fileupload').fileupload({ 


     dataType: 'json', 
     url: '/VendorReport/UploadFiles', 
     autoUpload: true, 
     type: boolen, 
     Default:true, 
     success: function (msg) { 

      alert(msg); 

     } 
    }); 


<input id="fileupload" type="file" name="files[]"> 
<input type="submit" id="btnup" value="Upload" /> 
+1

세트'autoUpload를 : 거짓,' –

+0

내가 유지하는 경우 autoUpload : false 파일을 허용하지 않습니다. 파일 업로드에 파일을 허용해야하며 제출 버튼을 클릭 한 후 작업해야합니다. – Chintu

답변

1

당신은 설정하여 자동 업로드 동작을 중지 할 수 있습니다 autoUpload: false

$('#fileupload').fileupload({ 
    dataType: 'json', 
    url: '/VendorReport/UploadFiles', 
    autoUpload: false, 
    type: boolen, 
    Default:true, 
    success: function (msg) { 
     alert(msg); 

    } 
}); 

편집

버튼의 클릭에 파일을 업로드하려면

HTML

<input id="fileupload" type="file" name="files[]"> 
<input type="submit" id="btnup" value="Upload" /> 

jQuery를이

$(document).ready(function(){ 
    $("#btnup").click(function(){ 
     $('#fileupload').fileupload({ 
      dataType: 'json', 
      url: '/VendorReport/UploadFiles', 
      autoUpload: false, 
      type: boolen, 
      Default:true, 
      success: function (msg) { 
       alert(msg); 
      } 
     }); 
    }); 
}); 

편집

또는 공식적인 방법 따라 해당 설명서를 참조 ->How to start uploads with a button click

$('#fileupload').fileupload({ 
    dataType: 'json', 
    url: '/VendorReport/UploadFiles', 
    autoUpload: false, 
    type: boolen, 
    Default:true, 
    success: function (msg) { 
     alert(msg); 
    } 
    add: function (e, data) { 
     data.context = $('<button/>').text('Click to Upload') 
      .appendTo(document.body) 
      .click(function() { 
       data.context = $('<p/>').text('Uploading...').replaceAll($(this)); 
       data.submit(); 
     }); 
    } 
}); 
+0

제출 버튼을 클릭하면서 파일을 업로드하는 방법 ..? – Chintu

+0

@Chintu, 업데이트 된 답변을 시도해보고 알려주세요 –

+0

나중에 해결책을 얻었습니다. Thanks @ Log1c – Chintu

관련 문제