2012-07-21 2 views
0

는 여러 개의 파일을 jquery file upload 사용하여 업로드 한 후 페이지를 새로 고치려고 : 내 테스트 메시지가 각 개별 파일 업로드 완료 후 호출되는 몇 가지 이유를 들어jquery 파일을 여러 번 업로드 할 때까지 기다리는 방법은 무엇입니까?

을 나는 결국 한 번만이 전화를하려고 해요 파일이 업로드되었습니다. 이것이 가능한가?

HTML :

<form id="fileupload" action="server/php/" method="POST" enctype="multipart/form-data"> 
    <!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload --> 
    <div class="row fileupload-buttonbar"> 
     <div class="span7"> 
      <!-- The fileinput-button span is used to style the file input field as button --> 
      <span class="btn btn-success fileinput-button"> 
       <i class="icon-plus icon-white"></i> 
       <span>Add files...</span> 
       <input type="file" name="files[]" multiple> 
      </span> 
      <button type="submit" class="btn btn-primary start"> 
       <i class="icon-upload icon-white"></i> 
       <span>Start upload</span> 
      </button> 
     </div> 
    </div> 
    <!-- The loading indicator is shown during file processing --> 
    <div class="fileupload-loading"></div> 
    <br> 
    <!-- The table listing the files available for upload/download --> 
    <table role="presentation" class="table table-striped"><tbody class="files" data-toggle="modal-gallery" data-target="#modal-gallery"></tbody></table> 
</form> 

JQuery와

$('#fileupload').bind('fileuploadcompleted', function (e, data) { 
    e.preventDefault(); 

    // I would expect to see this after all files ahve uplaoded but I see it for each file upload ? 
    alert("Completed"); 

    //location.reload(); 
    ... 
}) 

답변

0

fileuploadadd 이벤트를 수신하고, 업로드가 얼마나 많은 파일이 알 수 있도록 각 시간이 증가 몇 가지 변수가 발생했을. 그런 다음 fileuploaddone 이벤트 처리기에서 다른 변수를 증가시켜 얼마나 많은 변수가 완료되었는지 알 수 있습니다. 두 파일이 동일하면 모든 업로드가 완료되므로 다시로드하십시오 (또는 다른 작업을 수행해야 할 수도 있습니다). 거기에 더 나은 해결책이 있어야하지만,이 하나는 작동합니다.

+0

불행하게도이 – Paul

+0

솔직히, 다음,이 플러그인이 아닌 것 같아 (예를 들어 너무 작은 등 파일)로 인해 fileuploadcompleted 이벤트 처리기가 오류를 가진 파일이 포함되지 않는다는 사실에 작동하지 않습니다 가장 강력한 솔루션. 나는 당신이 원하는 옵션을 가지고있는 많은 것을 Uploadify를 사용했다. 그러나 그것은 당신에게 달려있다. –

0

stop 이벤트는 모든 업로드가 완료된 후에 만 ​​트리거됩니다.

$('#fileupload').bind('fileuploadstop', function (e, data) { 
    location.reload(); 
}) 
관련 문제