In a PhoneGap app I tried to use camera using HTML5 input
tag like this.
Following is the code line that I tried to execute
<input id="imageHolder" type="file" accept="image/*" capture />
It works in iPhone but not in Android. What have I missed? Or is this not supported in Android?
After tapping on the field in Android nothing happens while in iPhone it acts like below
I see this is an old question, but the answer is not using HTML but JavaScript and a cordova plugin.
I used this plugin
Quite easy to use.
Example:
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);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With