Miriam
Miriam

Reputation: 969

Ext JS 3: Get data from fileuploadfield

I am using Ext.ux.FileUploadField in Ext JS 3.3.1. I need to get the file data from the form. Does anyone know if this is possible without submitting the form? I can see the filename but not the file data...

Thanks.

Upvotes: 0

Views: 1582

Answers (1)

user2146536
user2146536

Reputation: 11

// get a handle to the FileUploadField component (e.g. by ID)
var fp = Ext.getCmp('fileUploadField');

//add a handler to FileUploadField's fileselected event
fp.on('fileselected', this.onFileUploadFieldFileSelected, this);



// 'fileselected' event handler
onFileUploadFieldFileSelected : function(fp, fileName) {
    // get a handle to the selected file
    var selectedFile = fp.fileInput.dom.files[0];

    // read the contents of the file using FileReader and display content here
}

Upvotes: 1

Related Questions