0

I am using Dropzone for the uploading on MP3 and WAV files. I have set an upper limit file size of 100MB but for MP3's I want to set a limit of 15MB.

I can check the file size as soon as the add the file using the this.on("addedfile") event listener, but I can't seem to find a way to fail the upload. I'm aware that I can remove the file from the uploader before it uploads, but I don't want to remove it, just fail with an error. How can I do this?

$dropzone.dropzone({ maxFilesize: 100, maxFiles: (limit) ? limit : 25, acceptedFiles: 'audio/mp3, audio/wav', init: function () { this.on("addedfile", function(file) { if (file.type == 'audio/mp3' && (file.size / (1000 * 1000)) > 15) { console.log('MP3 too big'); } }); } }); 
1

1 Answer 1

2

I think in this case you should use the accept instead of the addedfile event, http://www.dropzonejs.com/#config-accept

$dropzone.dropzone({ maxFilesize: 100, maxFiles: (limit) ? limit : 25, acceptedFiles: 'audio/mp3, audio/wav', accept: function(file, done) { if (file.type == 'audio/mp3' && (file.size / (1000 * 1000)) > 15) { done('MP3 too big'); } else { done(); } } }); 
Sign up to request clarification or add additional context in comments.

1 Comment

not possible, as written in the official docs: This function will not be called if the file is too big or doesn't match the mime types.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.