|
|
@ -208,7 +208,7 @@ |
|
|
|
attachO.attach_type = "image"; |
|
|
|
attachO.attach_type = "image"; |
|
|
|
} |
|
|
|
} |
|
|
|
attachO.filename = handler.file.fileName; |
|
|
|
attachO.filename = handler.file.fileName; |
|
|
|
if (handler.maxlength == 1) { |
|
|
|
if (handler.maxLength == 1) { |
|
|
|
handler.attach_array[0] = attachO; |
|
|
|
handler.attach_array[0] = attachO; |
|
|
|
// handler.attach_array.push(attachO);
|
|
|
|
// handler.attach_array.push(attachO);
|
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -271,7 +271,7 @@ |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
attachO.filename = handler.file.fileName; |
|
|
|
attachO.filename = handler.file.fileName; |
|
|
|
} |
|
|
|
} |
|
|
|
if (handler.maxlength == 1) { |
|
|
|
if (handler.maxLength == 1) { |
|
|
|
handler.attach_array[0] = attachO; |
|
|
|
handler.attach_array[0] = attachO; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
handler.attach_array[current] = attachO; |
|
|
|
handler.attach_array[current] = attachO; |
|
|
@ -444,7 +444,8 @@ |
|
|
|
url: "", |
|
|
|
url: "", |
|
|
|
multiple: true, |
|
|
|
multiple: true, |
|
|
|
accept: "", // .png,.pdf,image/jpg,image/* 等
|
|
|
|
accept: "", // .png,.pdf,image/jpg,image/* 等
|
|
|
|
maxSize: -1 // 1024 * 1024
|
|
|
|
maxSize: -1, // 1024 * 1024
|
|
|
|
|
|
|
|
maxLength: -1 // 无限制, 与multiple配合使用
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
@ -463,7 +464,7 @@ |
|
|
|
var self = this, o = this.options; |
|
|
|
var self = this, o = this.options; |
|
|
|
// create the noswfupload.wrap Object
|
|
|
|
// create the noswfupload.wrap Object
|
|
|
|
// wrap.maxSize 文件大小限制
|
|
|
|
// wrap.maxSize 文件大小限制
|
|
|
|
// wrap.maxlength 文件个数限制
|
|
|
|
// wrap.maxLength 文件个数限制
|
|
|
|
var _wrap = this.wrap = this._wrap(this.element[0], o.maxSize); |
|
|
|
var _wrap = this.wrap = this._wrap(this.element[0], o.maxSize); |
|
|
|
// fileType could contain whatever text but filter checks *.{extension}
|
|
|
|
// fileType could contain whatever text but filter checks *.{extension}
|
|
|
|
// if present
|
|
|
|
// if present
|
|
|
@ -545,30 +546,39 @@ |
|
|
|
var self = this; |
|
|
|
var self = this; |
|
|
|
event.add(wrap.dom.input, "change", function () { |
|
|
|
event.add(wrap.dom.input, "change", function () { |
|
|
|
event.del(wrap.dom.input, "change", arguments.callee); |
|
|
|
event.del(wrap.dom.input, "change", arguments.callee); |
|
|
|
for (var input = wrap.dom.input.cloneNode(true), i = 0, files = F(wrap.dom.input); i < files.length; i++) { |
|
|
|
var input = wrap.dom.input.cloneNode(true); |
|
|
|
var item = files.item(i); |
|
|
|
var files = F(wrap.dom.input); |
|
|
|
var tempFile = item.value || item.name; |
|
|
|
if (wrap.maxLength !== -1 && wrap.maxLength < files.length) { |
|
|
|
var value = item.fileName || (item.fileName = tempFile.split("\\").pop()), |
|
|
|
BI.Msg.toast(BI.i18nText("BI-Upload_File_Count_Error"), { level: "error" }); |
|
|
|
ext = -1 !== value.indexOf(".") ? value.split(".").pop().toLowerCase() : "unknown", |
|
|
|
self.fireEvent(BI.File.EVENT_ERROR, { |
|
|
|
size = item.fileSize || item.size; |
|
|
|
errorType: 2 |
|
|
|
var validateFileType = fileTypeValidate(value, wrap.fileType); |
|
|
|
}); |
|
|
|
if (!validateFileType) { |
|
|
|
} else { |
|
|
|
// 文件类型不支持
|
|
|
|
for (var i = 0; i < files.length; i++) { |
|
|
|
BI.Msg.toast(BI.i18nText("BI-Upload_File_Type_Error"), { level: "error" }); |
|
|
|
var item = files.item(i); |
|
|
|
self.fireEvent(BI.File.EVENT_ERROR, { |
|
|
|
var tempFile = item.value || item.name; |
|
|
|
errorType: 0, |
|
|
|
var value = item.fileName || (item.fileName = tempFile.split("\\").pop()), |
|
|
|
file: item |
|
|
|
ext = -1 !== value.indexOf(".") ? value.split(".").pop().toLowerCase() : "unknown", |
|
|
|
}); |
|
|
|
size = item.fileSize || item.size; |
|
|
|
} else if (wrap.maxSize !== -1 && size && wrap.maxSize < size) { |
|
|
|
var validateFileType = fileTypeValidate(value, wrap.fileType); |
|
|
|
// 文件大小不支持
|
|
|
|
if (!validateFileType) { |
|
|
|
BI.Msg.toast(BI.i18nText("BI-Upload_File_Size_Error"), { level: "error" }); |
|
|
|
// 文件类型不支持
|
|
|
|
self.fireEvent(BI.File.EVENT_ERROR, { |
|
|
|
BI.Msg.toast(BI.i18nText("BI-Upload_File_Type_Error"), { level: "error" }); |
|
|
|
errorType: 1, |
|
|
|
self.fireEvent(BI.File.EVENT_ERROR, { |
|
|
|
file: item |
|
|
|
errorType: 0, |
|
|
|
}); |
|
|
|
file: item |
|
|
|
} else { |
|
|
|
}); |
|
|
|
wrap.files.unshift(item); |
|
|
|
} else if (wrap.maxSize !== -1 && size && wrap.maxSize < size) { |
|
|
|
// BI.Msg.toast(value);
|
|
|
|
// 文件大小不支持
|
|
|
|
|
|
|
|
BI.Msg.toast(BI.i18nText("BI-Upload_File_Size_Error"), { level: "error" }); |
|
|
|
|
|
|
|
self.fireEvent(BI.File.EVENT_ERROR, { |
|
|
|
|
|
|
|
errorType: 1, |
|
|
|
|
|
|
|
file: item |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
wrap.files.unshift(item); |
|
|
|
|
|
|
|
// BI.Msg.toast(value);
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
wrap.files.length > 0 && self.fireEvent(BI.File.EVENT_CHANGE, { |
|
|
|
wrap.files.length > 0 && self.fireEvent(BI.File.EVENT_CHANGE, { |
|
|
@ -602,6 +612,7 @@ |
|
|
|
name: input.name, // name to send for each file ($_FILES[{name}] in the server)
|
|
|
|
name: input.name, // name to send for each file ($_FILES[{name}] in the server)
|
|
|
|
// maxSize is the maximum amount of bytes for each file
|
|
|
|
// maxSize is the maximum amount of bytes for each file
|
|
|
|
maxSize: o.maxSize ? o.maxSize >> 0 : -1, |
|
|
|
maxSize: o.maxSize ? o.maxSize >> 0 : -1, |
|
|
|
|
|
|
|
maxLength: o.maxLength, |
|
|
|
files: [], // file list
|
|
|
|
files: [], // file list
|
|
|
|
|
|
|
|
|
|
|
|
// remove every file from the noswfupload component
|
|
|
|
// remove every file from the noswfupload component
|
|
|
|