• jcleblanc

    Hi VinayV,


    You could listen for the upload complete event (docs here), which will return an array of file objects (docs here). That should have enough information for you to validate the content that was uploaded.




    Comment actions Permalink
  • Ranjith Kumar S

    Hi jcleblanc,

                 But i want to validate the file type before upload complete. i have added a listener 'beforeupload' where i could retrieve the added files before upload, but i was not able to cancel the event in case of invalid file type. Check the code as below.

    uploader.on('beforeupload', (data) => {
    if (data != undefined) {
    var fileName = data[0].name;
    var ext = (-1 !== fileName.indexOf('.')) ? fileName.replace(/.*[.]/, '').toLowerCase() : '';
    var allowed = ['doc', 'docx', 'xls', 'xlsx', 'pdf'];

    if (!allowed.length) { return true; }

    for (var i = 0; i < allowed.length; i++) {
    if (allowed[i].toLowerCase() == ext) { return true; }

    alert('This file types are not allowed to upload!');
    return false;



    It would be great if you could help me resolve this issue.

    Comment actions Permalink

Please sign in to leave a comment.