通过onChange on input=file激活Sencha函数
SenchaTouch不支持输入类型文件,所以我尝试使用一些html来实现这一点通过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: {
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;
}
}