2012-01-28 122 views
0

我使用Valums在這偉大工程的那一刻文件上傳之前,但我想要做的就是這樣它計算在目標目錄中的文件數量,以檢查有不到修改指定數量的文件已經在那裏處理之前...Valums文件上傳計數處理

..所以我想我會把一個簡單的ajax函數做onson提交位(不知道它的技術名稱)檢查並返回true或假(根據文件計數的結果返回錯誤中止上傳過程)。我發現這個ajax調用會因爲某種原因而被中止(根據FireBug),每次我上傳一個文件時都會將錯誤返回爲「undefined」。

我想知道的是,如果Valums uploader有些特殊的問題,將不允許在onSubmit bit中發出ajax調用....或者我只是想說錯了。

代碼:

function createUploader(){ 

var uploader = new qq.FileUploader({ 
    element: document.getElementById('file-uploader'), 
    action: '/Scripts/FileUploader/server/uploadprocess.php', 
    debug: true, 
    multiple: true, 
    autoUpload: true, 
    dragDrop: true, 
    params: { 
     UpType: UpType, 
     UpRef: UpRef, 
     Thumb: Thumb 
    }, 

      onSubmit: function(id, fileName){ 

       // --- This is my check that's getting aborted ---- 
       // --- Made this async because I want it do do this first, not sure if right though --- 

       var NumFiles = $.ajax({ 
        type: "GET", 
       url: "CountImages.php", 
       async: true, 
       cache: false, 
       dataType: 'text', 
       data: "UpType=blaUp&UpRef=blaRef", 
       error: function(XMLHttpRequest, textStatus, errorThrown) {   

         // --- Ajax failed --- 
          alert("Oh Dear: " + textStatus + " and errorThrow: " + errorThrown.Status); 
         // --- showing "Oh Dear: error and errorThrow: undefined" --- 
        } 
       }).responseText; 

       if (NumFiles === "False") 
       { 
        return false; 
       } 

      }, 

      onComplete: function(id, fileName, responseJSON){ 

       // Do stuff 

      } 
}); 

}

任何幫助極大的讚賞。 丹

+0

我想達到同樣的,你可以分享你CountImages.php? – 2012-08-20 11:02:24

回答

0

我的愚蠢。被Ajax函數調用的腳本的URL是無效的。我期望這個錯誤與文件未找到類型響應,而不是未定義。