Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过onChange on input=file激活Sencha函数_File_Extjs_Controller_Touch_Onchange - Fatal编程技术网

通过onChange on input=file激活Sencha函数

通过onChange on input=file激活Sencha函数,file,extjs,controller,touch,onchange,File,Extjs,Controller,Touch,Onchange,SenchaTouch不支持输入类型文件,所以我尝试使用一些html来实现这一点 config: { html: '<input type="file" onchange="readURL(this);">', config:{ html:“”, 但我只能调用我的应用程序之外的函数 有人知道我如何调用controllerfunction吗?它不是很漂亮,但在Sencha Touch框架中实现此功能之前,它是一种变通方法。这是我在视图文件中使用的代码 config: {

SenchaTouch不支持输入类型文件,所以我尝试使用一些html来实现这一点

config: {
    html: '<input type="file" onchange="readURL(this);">',
config:{
html:“”,
但我只能调用我的应用程序之外的函数


有人知道我如何调用controllerfunction吗?

它不是很漂亮,但在Sencha Touch框架中实现此功能之前,它是一种变通方法。这是我在视图文件中使用的代码

config: {
    html: '<input type="file" onchange="readURL(this);">',
在photoToStore函数中,我得到照片的base64

photoToStore: function(photo) {
    var reader = new FileReader();      
    var img    = new Image();
    reader.readAsDataURL(photo.files[0]);                       

    reader.onload = function(e) {   
        img.src = e.target.result;                  
    }
}

在最后一步中,我将base64 sting发送到后端,我可以将照片作为文件进行保护。

找到解决方案了吗?
photoToStore: function(photo) {
    var reader = new FileReader();      
    var img    = new Image();
    reader.readAsDataURL(photo.files[0]);                       

    reader.onload = function(e) {   
        img.src = e.target.result;                  
    }
}