Ext JS 3:从fileuploadfield获取数据

时间:2011-08-18 14:36:18

标签: javascript file-upload extjs extjs3

我在Ext JS 3.3.1中使用Ext.ux.FileUploadField。我需要从表单中获取文件数据。有没有人知道如果没有提交表格这是否可行?我可以看到文件名但不能看到文件数据......

感谢。

1 个答案:

答案 0 :(得分:1)

// 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
}