2011-08-18 67 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 
}