我正在使用Uploadify進行實時應用程序,至此它的工作正常,除了這一個問題。我有6個瀏覽按鈕可以上傳6個文件(每個文件有多個'true'),我的頁面上也有一個提交按鈕(JSP)。如何在進度條顯示前防止表單提交
如果用戶在這些瀏覽按鈕的任何一個上選擇了一個文件,那麼在選擇該文件後顯示進度欄之前會有一些延遲。與此同時,如果用戶點擊提交按鈕,表單甚至在進度條顯示之前被提交,並且沒有文件被上傳。我查看了可用的方法,但仍無法找到解決方案。
我非常感謝並期待在這件事情上有任何幫助。
謝謝。
請在下面找到我的代碼:
$("#vehShortTestAttachment1").uploadify({
'uploader' : '../pts/swf/uploadify.swf',
'script' : url,
'cancelImg' : '../pts/images/cancel.png',
'wmode' : 'transparent',
'hideButton': 'true',
'width' : 67,
'height' : 20,
'multi' : true,
'sizeLimit' : 20971520,
'fileDesc' : 'jpg, gif, doc, ppt, jpeg, txt, pdf',
'fileExt' : '*.jpg;*.gif;*.doc;*.ppt;*.jpeg;*.txt;*.pdf',
'onCancel': function() {
$('#attachments-div-validation').html("");
isFileBig = false;
},
'onSelectOnce': function (event, queueID, fileObj) {
$("#attachments-submit-case-button").attr("disabled", true);
},
'onSelect': function (event, queueID, fileObj) {
$("#attachments-div-validation").html(div_validation_red_start + "<B>You can select other files (or) Submit the Case now.</B>" + div_validation_red_end);
$("#attachments-div-validation").show();
if (fileObj.size > 20971520)
{
$('#attachments-div-validation').html(div_validation_red_start + "Size of the file: " + fileObj.name + " exceeds 20MB and this file can not be uploaded. <br>Please click on the X button on the progress bar for this file to cancel the upload. <br>Please click on BROWSE button again to upload another file." + div_validation_red_end);
$('#attachments-div-validation').show();
isFileBig = true;
}
},
'onComplete': function(event, queueID, fileObj, response, data)
{
if(response == 'OK') {
$('input[name=fileUploadStatus]').val(response);
$("#vehShortTestAttachment1").uploadifySettings('script', url);
}
else {
$('input[name=fileUploadStatus]').val(response);
$('#vehShortTestAttachment1').uploadifyCancel(queueID);
$('#vehShortTestAttachment1').uploadifyClearQueue();
}
},
'onAllComplete':function(event, data)
{
$("#attachments-submit-case-button").attr("disabled", false);
if(!isFileBig)
submitFormDetails();
}
});
優秀的@John_Doe:D – TheVillageIdiot 2010-10-11 17:39:01
上述兩種方法都無效。即使在進度條顯示之前用戶單擊提交按鈕,上傳隊列也沒有任何內容。 onSelectOnce也沒有工作。任何其他想法?我如何阻止用戶提交表單? – Radhika 2010-10-11 17:50:00
你能否提供一些更多的細節? 「onSelectOnce也不起作用」並不真正有幫助。事件觸發,當文件被選中時。所以這個事件發生在上傳開始之前。這是最早的反應機會。 – Andreas 2010-10-11 18:09:22