Blu*_*Blu 14 html5 android ios cordova
在PhoneGap应用程序中,我尝试使用input像这样的HTML5 标签的相机.
以下是我尝试执行的代码行
<input id="imageHolder" type="file" accept="image/*" capture />
Run Code Online (Sandbox Code Playgroud)
它适用于iPhone但不适用于Android.我错过了什么?或Android不支持此功能?点击Android中的字段后没有任何反应,而在iPhone中它的行为如下

我发现这是一个老问题,但答案不是使用 HTML,而是使用 JavaScript 和 cordova 插件。
我用过这个插件
非常容易使用。
例子:
if (device.platform == "Android") { //Here we check to see what OS is used. input with type file is supported on iOS, but not Android. So use plugin for Android
fileStorage.open(function (uri) {
if (callback) {
callback(uri);
}
return uri;
}, function (ex) {
throw ex;
});
} else {
var file = document.createElement("input");
file.type = "file";
file.accept = ".pdf";
file.style.display = "none";
document.body.appendChild(file);
file.click();
file.onchange = function (f) {
console.log(f);
console.log(file.files);
var reader = new FileReader()
reader.readAsDataURL(file.files[0]);
reader.onloadend = function () {
if (callback) {
callback(reader.result);
}
return reader.result;
}
document.body.removeChild(file);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10418 次 |
| 最近记录: |