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
}
});
}
任何帮助极大的赞赏。 丹
我想达到同样的,你可以分享你CountImages.php? – 2012-08-20 11:02:24