2016-07-11 2 views
0

dropzone.js 라이브러리를 사용하여 잠시 둘러보고 놀았으며 maxfilesexceeded event이 실행되지 않습니다. 정보에 대한 How to limit the number of dropzone.js files uploaded? 게시물을보고 최신 버전의 라이브러리로 업데이트했지만 이벤트는 여전히 발생하지 않습니다.dropzone.js maxfilesexceeded 이벤트가 실행되지 않음

위의 게시물에서 제안한 것처럼 init() 함수에서 수신기를 초기화하고 있습니다. 나는 maxfilesreached 이벤트를 잡을 수 있어요하지만 maxfilesexceeded 이벤트를 제외하고 예상대로되지 maxfilesexceeded 이벤트

$scope.fileUploadConfig = { 
    options: { 
     url: uploadFileURL, 
     maxThumbnailFilesize: 200, 
     maxFiles: 5, 
     uploadMultiple: false, 
     acceptedFiles: "application/vnd.oasis.opendocument.text,application/rtf,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,.xls,.xlsx,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,.ppt,.pptx,image/*,.mp3,.m4a,.ogg,.wav,.wma", 
     addRemoveLinks: true, 
     paramName: "file", 
     dictRemoveFile: "Remove", 
     clickable: true, 
     previewTemplate: $("#dropzone-preview-template").html(), 
     init: function() { 
      var instance = this, 
       selectedPageId = 0; 

      instance.on("success", function(event, data) { 
       /* ... */ 
      }); 

      instance.on("addedfile", function() { 
       /* ... */ 
      }); 

      instance.on("removedfile", function(file) { 
       /* ... */ 
      }); 

      instance.on("maxfilesreached", function(file) { 
       alert("MAX_FILES_REACHED"); 
      }); 

      instance.on("maxfilesexceeded", function(file) { 
       alert("MAX_FILES_EXCEEDED"); 
      }); 
     } 
    } 
}; 

모든 코드가 작동하고있는 것입니다.

답변

0

내가 울부 짖는이 테스트 케이스를 만들 : 당신이 AngularJS와와 dropzonejs 후크 때

Dropzone.autoDiscover = true; 
 
Dropzone.options.fbDropZone = { 
 
    init: function() { 
 
     instance = this; 
 
     instance.on("maxfilesreached", function(file) { 
 
       alert("MAX_FILES_REACHED"); 
 
     }); 
 
     instance.on("maxfilesexceeded", function(file) { 
 
       alert("MAX_FILES_EXCEEDED"); 
 
     }); 
 
    }, 
 
    previewTemplate: '<div class="dz-preview dz-file-preview"><div class="dz-details"><div class="dz-filename"><span data-dz-name></span></div><div class="dz-size" data-dz-size></div><img data-dz-thumbnail /></div><div class="dz-progress"><span class="dz-upload" data-dz-uploadprogress></span></div><div class="dz-success-mark"><span>✔</span></div><div class="dz-error-mark"><span>✘</span></div><div class="dz-error-message"><span data-dz-errormessage></span></div></div>', 
 
    paramName: "file", 
 
    maxFiles: 1, 
 
    autoProcessQueue: false 
 
};
#drop_zone { 
 
    width: 50%; 
 
    border: 2px dashed #BBB; 
 
    border-radius: 5px; 
 
    padding: 25px; 
 
    text-align: center; 
 
    color: #BBB; 
 
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.3.0/dropzone.js"></script> 
 
<div id='drop_zone'> 
 
    <form action="/uploads.php" class='dropzone' id='fbDropZone'></form> 
 
</div>

, 당신은 더 나은 dropzonejs

+0

안녕 보웬에 대한 지침을 작성, 이것은 maxfilesreached 이벤트에 대한 작업 하지만 maxfilesexceeded 이벤트로 실행할 수 있었습니까? 내 질문에 나는이 이벤트가 잘 작동하지만 maxfilesexceeded가 아니라고 썼다. 또한 지시문이 작동하고 다른 모든 이벤트가 정상적으로 실행되므로 지시문에 추가 할 때 이점이 나타나지 않습니다. – SM3RKY

+0

@ SM3RKY, 방금 "maxfilesExceeded"이벤트를 추가하면 두 번째 파일을 업로드 할 때 발생합니다. –

+0

도와 주셔서 감사합니다. 기회가 생겼을 때 조금 더 살펴볼 것입니다.하지만 지금은 답을 높여 줄 것입니다. 불행히도 투표 한 사람 만 투표 할 수 있습니다. – SM3RKY