我在Ext JS 3.3.1中使用Ext.ux.FileUploadField。我需要从表单中获取文件数据。有没有人知道如果没有提交表格这是否可行?我可以看到文件名但不能看到文件数据......
感谢。
答案 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
}