亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

現在的情況是alert已經出來了,可是文件還是上傳上去了?

現在的情況是alert已經出來了,可是文件還是上傳上去了?

開心每一天1111 2022-10-19 15:15:47
功能是要上傳一個文件,判斷這個文件名稱是否已存在,存在的話提示用戶修改文件名稱。Java代碼  'onSelect': function(e, queueId, fileObj) {  if(checkFileNames(fileObj.name)){  alert("已存在名為:" + fileObj.name + "的文件,請修改文件名稱!");  return false;  }  },  onSelect方法如上面所示,checkFileNames用于判斷文件名是否已存在,存在返回true,不存在返回false?,F在的情況是alert已經出來了,可是文件還是上傳上去了。怎么破?求大神~!~
查看完整描述

2 回答

?
胡說叔叔

TA貢獻1804條經驗 獲得超8個贊

做過類似的東西,是在onUploadStart中判斷的,弄了好久才搞定
'onUploadStart': function (file) {

    var myself = this;
    if(已存在){
      myself.cancelUpload(file.id);
      $('#' + file.id).remove();
    }
}


是根據uploadify源碼中改的

// Triggered right before a file is uploaded
        onUploadStart: function (file) {
            // Load the swfupload settings
            var settings = this.settings;

            var timer = new Date();
            this.timer = timer.getTime();
            this.bytesLoaded = 0;
            if (this.queueData.uploadQueue.length == 0) {
                this.queueData.uploadSize = file.size;
            }
            if (settings.checkExisting) {
                $.ajax({
                    type: 'POST',
                    async: false,
                    url: settings.checkExisting,
                    data: { filename: file.name },
                    success: function (data) {
                        if (data == 1) {
                            var overwrite = confirm('A file with the name "' + file.name + '" already exists on the server.\nWould you like to replace the existing file?');
                            if (!overwrite) {
                                this.cancelUpload(file.id);
                                $('#' + file.id).remove();
                                if (this.queueData.uploadQueue.length > 0 && this.queueData.queueLength > 0) {
                                    if (this.queueData.uploadQueue[0] == '*') {
                                        this.startUpload();
                                    } else {
                                        this.startUpload(this.queueData.uploadQueue.shift());
                                    }
                                }
                            }
                        }
                    }
                });
            }

查看完整回答
反對 回復 2022-10-24
?
德瑪西亞99

TA貢獻1770條經驗 獲得超3個贊

上傳動作我記得好像不是在onSelect里面觸發的,因此即使你在onSelect里面return false;不會Break掉上傳的動作。

查看完整回答
反對 回復 2022-10-24
  • 2 回答
  • 0 關注
  • 143 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號