Sencha touch 2.3.1 file upload not working xtype:filefield not working

I am trying to upload an image using sencha touch 2.3.1. After googling I found that I can use xtype:fileinput and xtype:filefield for capturing files from both gallery and camera.

Here are the contents of items array in my View

items : [
            {
               xtype : 'filefield',
               name : 'coverPicImage',
               accept: 'image',
               label : 'Cover pic'
            }
        ]

Here is the controller

config: {
    refs :{
        coverPicFile : 'uploadform filefield[name=coverPicImage]',
        submitButton : 'uploadform button[action=submit]'
     },
    control: {
        submitButton:   {
            tap : 'onSubmit'
        }
    }
}

onSubmit : function(){
    var coverPicInput = this.getCoverPicFile().input;
    var files = coverPicInput.dom.files;
}

The problem is this.getCoverPicFile().input is undefined. this.getCoverPicFile() returns a class.

If I change filefield to fileinput it works fine.

The error which I get is

Uncaught TypeError: Cannot read property 'dom' of undefined 

Is there any reason for why this is not working with filefield

Thanks in advance

Answers


I lost a lot of time on this, in the end i managed to get the pic and upload it to server in base64 format. This tutorial worked for me. Dont be fooled my the title this tutorial allow you to select the file/images from local filesystem.


Need Your Help

Add data to a react component

javascript reactjs

I'm building my first react component and am trying to add items to the parent component via an external click event. The user basically chooses from a list of search results and I want these to go...