1

我正在 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];” 行正在检索所有与文件相关的数据 -"File{size=879394,type="image/jpeg",name="Chrysanthemum.jpg", more...}" 那么如何获取和访问上传文件的实际内容?请帮我

4

0 回答 0