我正在使用extjs4处理文件上传功能。我将视图编码为 -
Ext.define('Balaee.view.kp.dnycontent.Content',
{
extend:'Ext.form.Panel',
requires:[
'Balaee.view.kp.dnycontent.ContentView'
],
id:'ContentId',
alias:'widget.Content',
title:'This day in a history',
items:[
{
xtype: 'fileuploadfield',
hideLabel: true,
emptyText: 'Select a file to upload...',
//inputType: 'file',
id: 'upfile',
//name:'file',
width: 220
}],
buttons: [{
xtype : 'button',
fieldlabel:'upload',
action:'upload',
name:'upload',
text: 'Upload',
formBind:'true'
}]
});
在控制器中获取文件我编写了代码 -
getUpload : function() {
var fileobj = Ext.getCmp('upfile');
var file10 = Ext.getCmp('ContentId').getEl().down('input[type=file]').dom.files[0];
var reader = new window.FileReader();
reader.onload = function(oFREvent) {
fileobj=oFREvent.target.result;
console.log(oFREvent.target.result);
};
var storeObj=this.getStore('kp.DnycontentStore');
console.log(storeObj);
storeObj.load({
params:{
data:file
},
callback: function(records,operation,success){
console.log("send");
},
scope:this
})
console.log(storeObj);
}
});
所以“var file10 = Ext.getCmp('ContentId')。getEl()。down('input [type = file]')。dom.files [0];” line正在检索所有文件相关数据as- "File{size=879394,type="image/jpeg",name="Chrysanthemum.jpg", more...}"
那么如何获取和访问上传文件的实际内容?请帮帮我