Reputation: 3
i got uploadifive uploader and i have to remove file from server when user clicks X button. Any ideas? :) Thanks!
http://prntscr.com/25qdla screenshot of uploaded file`s content.
current code:
$('#file_upload').uploadifive({
'formData' : {
'timestamp' : '<?php echo $timestamp;?>',
'token' : '<?php echo md5('unique_salt' . $timestamp);?>'
},
'fileSizeLimit' : '500MB',
'itemTemplate' : '<p class="files uploadifive-queue-item"><i onclick="removeFile()" class="ico close" style="cursor: pointer;" title="<?=$this->lang->line('modadd_4_filespan_delete');?>"></i><span class="filename"></span><span class="fileinfo"></span></p>',
'queueID' : 'ify_queue',
'uploadScript' : 'uploaders/wv_ify',
'buttonText' : '<a style="margin-top: -7px; margin-left: -16px; height: 38px; width: 132%; cursor: pointer;"><?=$this->lang->line('modadd_4_files_button_text');?></a>',
'method' : 'post',
'fileTypeExts' : '*.rar;*.zip;*.7z;*.scs;',
'onUpload' :function(file) {
$("#msg_error_display, #msg_success_display").hide();
$("#msg_error_display").fadeIn(100, function(){
$(this).find('span').html("<?=$this->lang->line('modadd_4_uploading_files');?>");
});
checker = 0;
},
'onQueueComplete':function(file, data) {
$("#msg_error_display, #msg_success_display").hide();
if(checker == 0){
$("#msg_success_display").fadeIn(100, function(){
$(this).find('span').html("<?=$this->lang->line('modadd_4_uploading_files_end');?>")
});
} else if(checker == 1){
$("#msg_error_display").fadeIn(100, function(){
$(this).find('span').html("<?=$this->lang->line('modadd_4_uploading_files_stop');?>")
});
}
},
'onError' : function(errorType) {
$("#msg_error_display, #msg_success_display").hide();
checker = 1;
},
'onProgress' : function() {
console.log(e.bytesloaded);
},
'onUploadComplete' : function() {
console.log($('.uploadifive-queue-item').find(".fileinfo").html(""));
$("#no_files_uploaded").hide();
uploaded_files += 1;
all_uploaded_files += 1;
}
});
Upvotes: 0
Views: 973
Reputation: 26
I have the same problem, We have 2 properties uploadScript and checkScript, I think could have a propertie like removeScript which we implement a script to delete the file.
But how there isn`t,
We can implement onCancel event with some ajax to call this script, you can make a code like this (add this onCancel on your code):
$('#file_upload').uploadifive({
// Other Atributes and Methods
// onCancel event implement with ajax to remove files
// the argument "file" has many attributes
// how name, which you use to delete file on server
// remeber argument file is an json object
onCancel : function(file) {
$.post('ajax-method-with-delete.php',file)
}
});
Upvotes: 1