Is it possible to select multiple files in the file upload window using extjs 5?
Just adding attribute multiple:''
like this:
var fileUploadButton = new Ext.create('Ext.form.field.File', {
buttonOnly: true,
hideLabel: true,
buttonText: 'Upload Files...',
fileInputAttributes: {
accept: 'application/xml',
multiple: ''
});
If you want to show names of the files you can make something like this:
Ext.define('Ext.form.field.MyFile', {
extend: 'Ext.form.field.File',
alias: 'widget.multiplefileuploadfield',
multiple: true,
afterRender: function(){
var me = this;
me.callParent(arguments);
if(me.multiple){
me.fileInputEl.set({
multiple:'multiple',
name: me.name ? me.name + '[]' : 'files[]'
});
}
}
});
Ext.define('Ext.form.field.FileButtonOverride', {
override: 'Ext.form.field.FileButton',
fireChange: function(e){
var inp = this.fileInputEl.dom;
if(!inp.files || !window.FileReader || !inp.files.length){
this.fireEvent('change', this, e, inp.value);
return;
}
var arrValues = [];
for (var i = 0; i < inp.files.length; ++i) {
arrValues.push(inp.files.item(i).name);
}
this.fireEvent('change', this, e, arrValues.join(', '));
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With