2013-07-16 27 views
1

我想獲得用戶對文件提交的響應取消或不取消文件上傳,但它似乎並沒有停止文件上傳可能是我缺少的東西請建議Fineuploader取消上傳文件提交後的用戶響應

onSubmit: function(id, name) { 
        doc_status = $('#doc_attach_status').val(); 
           if (doc_status == "true") { 

         if(confirm("Please note, if you upload a new PDF, old one will be replaced") == false){ 

           manualuploader.cancelAll(); // tried but does not work  
          cancelAll();// tried but does not work 
          cancel(id);// tried but does not work 
          $(this).cancelAll();// tried but does not work 
          } 

        } 

       }, 

是的,我能成功上傳的文件......

這是我使用的功能齊全...

var manualuploader = new qq.FineUploader({ 
      callbacks : { 
       onComplete : function(id, name, response) { 
       } 
      }, 
      element : $('#pdf-fine-uploader')[0], 
      request : { 

       endpoint : "/UploadPdf", 
       params : { 
        variant_id : $('#variant_id').val(), 
       } 
      }, 
      multiple : false, 
      autoUpload : true, 
      text : { 
       uploadButton : '<i class="icon-plus icon-white"></i> Select File </br> Maximum upload size less than 2 MB' 
      }, 
      validation : { 
       allowedExtensions : ['pdf', 'txt'], 
       //sizeLimit: 51200, // 50 kB = 50 * 1024 bytes 
       sizeLimit : 2097152//, // 2 MB = 2 * 1024 * 1024 bytes 
       //itemLimit : 6 
      }, 
      callbacks : { 

       onSubmit: function(id, name) { 
        doc_status = $('#doc_attach_status').val(); 
        // var answer = confirm("Please note, if you upload a new PDF, your current Tasting Notes PDF will be replaced"); 
        if (doc_status == "true") { 

         if(confirm("Please note, if you upload a new PDF, your current Tasting Notes PDF will be replaced") == false){ 

           manualuploader.cancelAll();  

          } 

        } 

       },     
       onComplete : function(id, fileName, responseJSON) { 
        if (responseJSON.success) { 
         $('.doc_link').html(responseJSON.docurl); 
         $('#doc_delete_link').addClass('icon-remove-sign'); 
         $('.doc_description_head').show(); 
         $('#doc_pdf_head').show(); 
         $('.doc_description_div').show(); 
         $('.description_save').show(); 
          $('#doc_delete_link').show(); 
        } 
       } 

      } 

     }); 
     $('#triggerUpload').click(function() { 
      manualuploader.uploadStoredFiles(); 
     }); 

    }); 
+2

作爲文檔狀態,你可以在你的onsubmit回調返回false要求精細上傳忽略相關的文件。 –

回答

1

最後得到了非常簡單的解決方案...

只使用

retrun真或假的獲取用戶的響應之後....

onSubmit: function(id, name) { 
       doc_status = $('#doc_attach_status').val(); 
          if (doc_status == "true") { 

        if(confirm("Please note, if you upload a new PDF, old one will be replaced") == false){ 

         retutn false; 
         } 

       } 

      }, 
相關問題