jquery - Uploadify: How to remove uploaded items from queue -
i'm trying uploadify clear upload queue delete uploaded files. problem this. if upload 5 files (with uploadlimit
of 5 set), upload first time. if clear queue using this:
<a class="button" href="javascript:jquery('#attachment').uploadify('cancel', '*');">clear upload queue</a>
it removes files visually screen, still can't uploaded more files. tried using:
jquery('#attachment').uploadify('settings', 'uploadlimit', 5)
in onqueueclear
doesn't reset uploadlimit
. how can reset uploadlimit
after queue has been cleared? here code:
jquery('#attachment').uploadify({ swf: '/javascript/uploadify/uploadify.swf', uploader: '/javascript/uploadify/uploadify.php', uploadfolder: 'temp', uploadtime: upload_time, uploadtoken: upload_token, cancelimage: '/javascript/uploadify/cancel.png', filetypeexts: '*.jpg; *.gif; *.png; *.jpeg; *.doc; *.docx; *.zip; *.pdf; *.xls; *.xlsx; *.jpg', filetypedesc: 'allowed files', auto: true, multi: true, removecompleted: false, simuploadlimit: 1, filesizelimit: '3mb', allowedfiles: '*.jpg; *.gif; *.png; *.jpeg; *.doc; *.docx; *.zip; *.pdf; *.xls; *.xlsx; *.jpg', // allowedfiles: '*.cdt;*.con;*.doc;*.docx;*.dxd;*.gif;*.jpg;*.jpeg;*.key;*.lab;*.mov;*.mp4;*.m4v;*.pdf;*.png;*.pps;*.ppt;*.pptx;*.rst;*.txt;*.wmv;*.xls;*.xlsx;*.zip', uploadlimit: 5, width: 210, height: 40, buttontext: 'click add 5 attachments', buttonimage: '/images/content/mail/add-attachments.png', onuploadstart: function (file) { jquery('.submit').attr('disabled', 'disabled'); if (parseint($.cookie('size')) > 0) { $.cookie('size', parseint($.cookie('size')) + file.size); } else { $.cookie('size', file.size); } if (parseint($.cookie('size')) > 30000000) { alert('you have exceeded maximum queue size. please delete 1 or more files upload. can clear queue clicking button below.'); jquery('#attachment').uploadify('cancel', '*'); } }, onuploadsuccess: function (file, data, response) { jquery('.submit').removeattr('disabled'); try { obj = jquery.parsejson(data); if (obj.success) { jquery('#' + file.id).append('<input type="hidden" name="temp_image_path[]" value="' + obj.file.name + '" /><input type="hidden" name="original_name[]" value="' + obj.file.original_name + '" />'); } } catch (e) { // nothing } }, onuploaderror: function (file, errorcode, errormsg, errorstring) { alert('the file ' + file.name + ' not uploaded: ' + errorstring); }, onqueuecomplete: function () { jquery('.submit').removeattr('disabled'); }, onclearqueue: function (queueitemcount) { //jquery('.submit').attr('disabled', 'disabled'); var file = (queueitemcount == 1) ? 'file has' : 'files have'; alert(queueitemcount + ' ' + file + ' been removed upload queue. have no files pending upload.'); $.cookie('size', 0); jquery('#attachment').uploadify('settings', 'uploadlimit', 5); }, formdata: { 'filetypes': '*.jpg; *.gif; *.png; *.jpeg; *.doc; *.docx; *.zip; *.pdf; *.xls; *.xlsx; *.jpg', 'folder': 'temp', 'time': upload_time, 'token': upload_token } });
i failed find out-of-the-box solution too.the cancel
method affects not yet uploaded files.
i suggest can have custom handler deleting uploaded file (or files). somewhere near unlink
call. , can - not reset uploadlimit
5 increase uploadlimit
removed files count.
but uploadify object still have information uploaded files - means if user try load same files warning message duplicate files. can clear collection:
var files = $('#attachment').data('uploadify').queuedata.files = []; (var member in files) delete files[member];
it may not correct use code can extend plugin.
Comments
Post a Comment