2013-11-21 2 views
0

У меня есть uploadifive uploader, и мне нужно удалить файл с сервера, когда пользователь нажимает кнопку X. Есть идеи? :) Благодаря!Файл UploadiFive удаляет загруженный файл с сервера?

http://prntscr.com/25qdla скриншот содержимого загруженного файла.

текущий код:

   $('#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; 
        } 
       }); 

ответ

1

У меня такая же проблема, У нас есть 2 свойства uploadScript и checkScript, я думаю, что может иметь СВОЙСТВА как removeScript, который мы реализуем сценарий для удаления файла.

Но как там ISN `,

Мы можем реализовать OnCancel событие с некоторыми AJAX вызвать этот сценарий, вы можете сделать такой код (добавьте этот OnCancel на код):

$('#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) 
    } 
}); 
Смежные вопросы