xtype: 'filefield',
id: 'multipartFiles',
name: 'multipartFiles',
fieldLabel: '附件',
buttonText: '请选择',
inputWidth: 300,
allowBlank: false,
multipleFn: function ($this) { //多文件上传
var typeArray = ["application/x-shockwave-flash", "audio/MP3", "image/*", "flv-application/octet-stream"];
var fileDom = $this.getEl().down('input[type=file]');
fileDom.dom.setAttribute("multiple", "multiple");
fileDom.dom.setAttribute("accept", typeArray.join(","));
},
listeners: {
afterrender: function () {
this.multipleFn(this);
},
change: function () {
var fileDom = this.getEl().down('input[type=file]');
var files = fileDom.dom.files;
var str = '';
for (var i = 0; i < files.length; i++) {
str += files[i].name;
str += ' ';
}
Ext.getCmp('multipartFiles').setRawValue(str);
this.multipleFn(this);
}
}
测试发现IE8以下不太好用,IE8以上不知道,其他浏览器都正常
代码详细在我写的另一篇文章里。
文件上传
本文介绍了一个使用ExtJS框架实现的多文件上传组件,该组件允许用户选择多个指定类型的文件进行上传,如Flash、MP3、图片和FLV等。组件在IE8及以上版本和其他主流浏览器中表现良好,但在IE8以下版本中可能存在兼容性问题。文章还提到了通过修改文件域的属性来支持多文件选择,并监听文件变化以更新显示。
6604

被折叠的 条评论
为什么被折叠?



