Multiple file uploads Extjs 6 modern toolkit

975 Views Asked by At

I have done multiple file upload in Extjs Classic Now i want to implement it in Modern toolkit but there are issue there is no fileButton Field So i'm using filefield, But i'm not sure how can i get the file data from the filefield here is the code:

                             {
                                xtype: 'fieldset',
                                title: 'Attechments',
                                reference: 'attachmentfile',
                                padding: 10,
                                layout: {
                                    type: 'vbox',
                                    align: 'stretch'
                                },
                                defaults: {
                                    labelWidth: 130
                                },
                                items: [
                                    {
                                        xtype: 'filefield',
                                        text: 'Attach Files',
                                        name: 'files',
                                        listeners:{
                                            change: 'onFileChange'
                                        }
                                    }
                                ]
                            }

and in Viewcontroller:

onFileChange: function (field, e, value) {
       // how to get fileField data so that i can upload via ajax and attach //more files options
}
1

There are 1 best solutions below

0
On

In ExtJS 6 Classic Toolkit:

var file = filefield.fileInputEl.dom.files[0];

In ExtJS 6 Modern Toolkit:

var file = filefield.getComponent().getFiles()[0];

Classic demo here

Modern demo here