科尔多瓦inappbrowser和输入文件 [英] cordova inappbrowser and input file

查看:408
本文介绍了科尔多瓦inappbrowser和输入文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个iOS和Android应用程序,我在我的应用程序中加载一个外部网站(这个外部网站也是我的)。
我的问题是,这个网站有一个文件上传功能,这个功能不适用于Android(它适用于iOS)。
我看到这种行为在Android上是正常的,但有没有办法使它工作,或者它绝对不是一个选项?
谢谢

编辑1

我尝试创建新的应用程序,像这样一个简单的页面(在AWS上托管):

$ p $ < html>
< head>
< title>上传测试!< /标题>
< / head>
< body>
< div>上载测试< / div>
< div>
< input type =fileid =imgFilename =files []accept =image / x-png,image / gif,image / jpeg>
< / div>
< / body>



我在我的Cordova项目中生成了index.html。

$ p $ < script type =text / javascript>
document.addEventListener(deviceready,function(event){
console.log('TEST CONSOLE LOG!');
var url ='https:// s3-eu-west -1.amazonaws.com/***/file-upload.html';
ref = window.open(url,_blank,location = no,toolbar = no,zoom = no,hidden = yes );

ref.addEventListener('loadstop',function(){
ref.show();
});
ref.addEventListener('loaderror ',function(){
ref.close();
ref = undefined;
});
},false);
< / script>

它不适用于我的nexus 5(android M)。

解决方案 > 然而,它不能通过他的安装指南安装...所以这里是我的:

  cordova plugin删除cordova-plugin-inappbrowser -camera 
cordova插件添加https://github.com/jverlee/cordova-plugin-inappbrowser-camera.git

顺便说一下,如果我按照他的指导,我只会得到:
错误:无法读取未定义的属性'变量'

I have a iOS and Android application, and I load a external website inside my app (this external website is mine too). My problem is that this website has a file upload feature and this feature does not work on Android (it works on iOS). I saw that this behavior is normal on Android, but is there any way to make it work or it's definitely not an option ? Thank you

EDIT 1

I tried to create a new app with a simple page like this (hosted on AWS) :

<html>
<head>
    <title>Upload Test !</title>
</head>
<body>
    <div>Upload Test</div>
    <div>
        <input type="file" id="imgFile" name="files[]" accept="image/x-png, image/gif, image/jpeg">
    </div>      
</body>

and I added this script in my generated index.html in my Cordova project.

    <script type="text/javascript">
        document.addEventListener("deviceready", function(event) {
            console.log('TEST CONSOLE LOG !');
            var url = 'https://s3-eu-west-1.amazonaws.com/***/file-upload.html';
            ref = window.open(url, "_blank", "location=no,toolbar=no,zoom=no,hidden=yes");

            ref.addEventListener('loadstop', function () {
              ref.show();
            });
            ref.addEventListener('loaderror', function () {
              ref.close();
              ref = undefined;
            });
        }, false);
    </script>

It doesn't work on my nexus 5 (android M).

解决方案

@Verl's code is pretty good! However, it cannot be installed through his installation guide... So here is mine:

cordova plugin remove cordova-plugin-inappbrowser-camera
cordova plugin add https://github.com/jverlee/cordova-plugin-inappbrowser-camera.git

By the way, if I follow his guide, I only gets: Error: Cannot read property 'variables' of undefined

这篇关于科尔多瓦inappbrowser和输入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆