3

I am using uploadifive plugin for multi-file uploading. It works great but now i have find a bug in my implementation that queue is not clearing after creating a record. If record is created then uploadifive should show empty queue for new record but it shows old queued files which were previously uploaded. My logic is Ajax and java-script driven and i am not refreshing page after form get submitted(if page refreshed then queue is white and clean which is obvious :) ).

Following is the code which i used to activate uploadifive for my file type input:

$('#xyz_uploader').uploadifive({
    'fileTypeDesc' : 'Image Files',
    'fileTypeExts' : '*.png;*.jpg;*.jpeg',
    'fileType'  : ['image/png','image/jpg','image/jpeg'],
    'auto'             : false,
    'checkScript'      : 'uploadify_envc.php?checkexist=true',
    'formData'         : {
        'timestamp' : curDateTime,

        'token'     : 'df324523adg34qtfgiui',
        'doc_type'     : 'docs',
        'somenewval'     : $("select#dropdown_control").val(),
    },
    'buttonText'          : 'Upload Document(s)',
    'queueID'          : 'xyz_uploader_queue',
    'auto'     : true,
    'uploadScript'     : 'uploadify_envc.php?injury='+$("select#dropdown_control").val(),
    'onUploadComplete' : function(file, data) { HandleUploadiFiveDocs(file,data,"docs");    }
});

When i submitting data using JS function, i call this function in return of Ajax call to clear queued files:

    $('#xyz_uploader').uploadifive('clearQueue');

But this is not working. I have tested it via browser console and in java-script function but both are not working.

So can you guys tell me that how can i clear uploadifive queue using java-script command?

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
Star
  • 3,222
  • 5
  • 32
  • 48
  • 2
    I know that jquery and JavaScript logic can do that, e.g. .remove() etc but i want to know that what this plugin offer? As this is widely used plugin so hopefully there will be developer who might faced this in past and now have solution so please post it for other as well. – Star Jul 31 '17 at 12:21
  • 2
    Did you try using `.uploadifive('cancel', '*')`? I know that its a part of Uploadify, not Uploadifive, but since I even don't have access to source code (because its paid), this is worth a try. – 31piy Aug 04 '17 at 09:41
  • 2
    I didn't completely understand. Did `.uploadifive('cancel', '*')` worked? I don't actually have an answer. It was just a guess. If it worked, I can post it as an answer. – 31piy Aug 04 '17 at 09:55
  • check my answer. $('#xyz_uploader').uploadifive('destroy') this worked for me. it destroy object and then recreate it. – Star Aug 04 '17 at 09:58

2 Answers2

2

Add this line of code in your 'onUploadComplete' function

$(this).uploadifive('cancel', $('.uploadifive-queue-item').data('file'));

or

$('#xyz_uploader').uploadifive('cancel', $('.uploadifive-queue-item').data('file'));
Nabeel
  • 841
  • 1
  • 10
  • 23
1

first using

$('#xyz_uploader').uploadifive('destroy') 

and then re-constructing object worked for me. Like following :

$('#xyz_uploader').uploadifive({
    'fileTypeDesc' : 'Image Files',
    'fileTypeExts' : '*.png;*.jpg;*.jpeg',
    'fileType'  : ['image/png','image/jpg','image/jpeg'],
    'auto'             : false,
    'checkScript'      : 'uploadify_envc.php?checkexist=true',
    'formData'         : {
        'timestamp' : curDateTime,

        'token'     : 'df324523adg34qtfgiui',
        'doc_type'     : 'docs',
        'somenewval'     : $("select#dropdown_control").val(),
    },
    'buttonText'          : 'Upload Document(s)',
    'queueID'          : 'xyz_uploader_queue',
    'auto'     : true,
    'uploadScript'     : 'uploadify_envc.php?injury='+$("select#dropdown_control").val(),
    'onUploadComplete' : function(file, data) { HandleUploadiFiveDocs(file,data,"docs");    }
});

Try it and it will work for you guys as well. i have found that while looking into core functions. Anyhow it was disappointing to get no support from here.

Star
  • 3,222
  • 5
  • 32
  • 48