您可以创建一个 xtype:
Ext.define('fileupload',{
extend: 'Ext.form.field.Text'
,alias: 'widget.fileupload'
,inputType: 'file'
,listeners: {
render: function (me, eOpts) {
var el = Ext.get(me.id+'-inputEl');
el.set({
size: me.inputSize || 1
});
if(me.multiple) {
el.set({
multiple: 'multiple'
});
}
}
}
});
并以您的形式使用它:
,items: [{
xtype: 'fileupload'
,vtype: 'file'
,multiple: true // multiupload (multiple attr)
,acceptMimes: ['doc', 'xls', 'xlsx', 'pdf', 'zip', 'rar'] // file types
,acceptSize: 2048
,fieldLabel: 'File <span class="gray">(doc, xls, xlsx, pdf, zip, rar; 2 MB max)</span>'
,inputSize: 76 // size attr
,msgTarget: 'under'
,name: 'filesToUpload[]'
}]
请参阅githab上的示例