2014-04-05 4 views
-1

Jquery File Upload가있는 양식이 있습니다. 양식은 다음과 같습니다jQuery 파일 업로드 - 양식에 파일 업로드

<form action="" method="post" name="job_offer_reply" id="job_offer_reply" enctype="multipart/form-data"> 
    <textarea name="description" id="description" class="form-control" rows="3"></textarea> 
    <div id="drop"> 
     <?php _e('Drop You CV Here', 'ja'); ?> 
     <a><?php _e('OR Browse', 'ja'); ?></a> 
     <input type="file" name="upl" multiple/> 
    </div>  
    <input id="submit" type="submit" class="btn btn-primary" name="submit" value="Submit"> 
</form> 

[파일 업로드 초기화 기능 (단축)입니다 :

$(function(){ 
    $('#drop a').click(function(){ 
     // Simulate a click on the file input button 
     // to show the file browser dialog 
     $(this).parent().find('input').click(); 
    }); 


    // Initialize the jQuery File Upload plugin 
    $('#job_offer_reply').fileupload({ 

     formData: { 
      action: 'ja_upload_cv', 
     }, 
     dropZone: $('#drop'), 
     add: function (e, data) { 

      // Automatically upload the file once it is added to the queue 
      var jqXHR = data.submit(); 
     }, 

     done:function(e, data){ 
      console.log(data); 
     }, 
     fail:function(e, data){ 
      // Something has gone wrong! 
      data.context.addClass('error'); 
     } 

    }); 
}); 

이 코드는 즉시이 선택의 파일을 업로드/떨어졌다. 삭제할 때

var jqXHR = data.submit(); 

양식 제출 후에도 전혀 제출되지 않습니다.

제출 버튼을 클릭하면 어떻게 파일을 업로드 할 수 있습니까? ($ _FILES 배열에 포함 시키십시오)?

add: function (e, data) { 
    $('#submit').click(function(){ 
     var jqXHR = data.submit(); 
    }; 
}, 
:

답변

0

그냥 이벤트 리스너를 사용하도록 add 콜백을 수정
관련 문제