2011-08-18 133 views
0

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

谢谢。

+0

您使用的是什么服务器端框架/语言? – Lloyd

+0

Java,Seam等。我希望能够做到这一点,但客户端。但如果这是不可能的,我会制作一个服务器端解决方案。 – Miriam

+0

你试过swfupload吗?这应该是这种情况下的最佳解决方案。但是,请记住...有时swf版本在任何浏览器中都是不同的..这可能会导致用户出错...最安全的方式是使用服务器端 –

回答

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 
}