Browse Source

KERNEL-12683 feat: 文件上传支持自定义校验 , bi.file reset方法清空前一次上传的files

es6
zsmj 2 years ago
parent
commit
221e254ea1
  1. 3
      src/base/single/editor/editor.multifile.js
  2. 13
      src/base/single/input/file.js

3
src/base/single/editor/editor.multifile.js

@ -43,12 +43,14 @@ BI.MultifileEditor = BI.inherit(BI.Widget, {
});
this.file.on(BI.File.EVENT_ERROR, function () {
self.fireEvent(BI.MultifileEditor.EVENT_ERROR, arguments);
self._reset();
});
this.file.on(BI.File.EVENT_PROGRESS, function () {
self.fireEvent(BI.MultifileEditor.EVENT_PROGRESS, arguments);
});
this.file.on(BI.File.EVENT_UPLOADED, function () {
self.fireEvent(BI.MultifileEditor.EVENT_UPLOADED, arguments);
self._reset();
});
BI.createWidget({
@ -93,7 +95,6 @@ BI.MultifileEditor = BI.inherit(BI.Widget, {
},
upload: function () {
this._reset();
this.file.upload();
},

13
src/base/single/input/file.js

@ -56,7 +56,7 @@
del: document.removeEventListener ?
function (node, name, callback) {
node.removeEventListener(name, callback, false);
return this;
} :
function (node, name, callback) {
@ -113,8 +113,8 @@
if (isFunction(handler.onerror)) {
handler.onerror();
}
return;
return;
}
for (var xhr = new XMLHttpRequest,
upload = xhr.upload || {
@ -245,7 +245,7 @@
form.append("FileData", handler.file);
xhr.send(form);
}
return handler;
};
} else {
@ -298,7 +298,7 @@
handler.onload(rpe, { responseText: responseText });
}
}
try { // IE < 8 does not accept enctype attribute ...
var form = document.createElement("<form enctype=\"multipart/form-data\"></form>"),
iframe = handler.iframe || (handler.iframe = document.createElement("<iframe id=\"" + target + "\" name=\"" + target + "\" src=\"" + url + "\"></iframe>"));
@ -353,7 +353,7 @@
};
}
xhr = null;
return sendFile;
}(Object.prototype.toString));
@ -705,6 +705,7 @@
reset: function () {
if (this.wrap) {
this.wrap.files = [];
this.wrap.attach_array = [];
this.wrap.attach_names = [];
this.wrap.attachNum = 0;

Loading…
Cancel
Save