gpt4 book ai didi

android - cordova inappbrowser 和输入文件

转载 作者:太空狗 更新时间:2023-10-29 14:48:15 26 4
gpt4 key购买 nike

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

编辑 1

我试着用这样一个简单的页面创建一个新的应用程序(托管在 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>

我在我的 Cordova 项目中生成的 index.html 中添加了这个脚本。

    <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)。

最佳答案

Android 和 iOS 都存在一个问题,当在 inappbrowser 中单击这样的文件输入标签时会阻止文件上传:

<input type="file">

我已将这两个修复程序合并到一个位置,以方便其他面临此问题的人轻松解决这两个问题。您应该能够修改您的 config.xml 文件以通过包含以下内容来使用它:

<plugin spec="https://github.com/jverlee/cordova-plugin-inappbrowser-camera.git" version="1.1.0" source="git" />

而不是默认的 inappbrowser 插件。

可以在这里找到更多详细信息: https://github.com/jverlee/cordova-plugin-inappbrowser-camera

关于android - cordova inappbrowser 和输入文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37642772/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com