Comments (6)
In case anyone is having issues figuring out how to load the image as base64
Place this code inside of the setOnPictureTakenHandler callback and make sure the file plugin is installed https://github.com/apache/cordova-plugin-file
//LOAD THE FILE AS BASE64
var reader = new FileReader();
reader.onloadend = function (evt) {
console.log(evt.target.result) // THIS IS THE IMAGE AS BASE64
};
reader.onerror = function (evt) {
};
//LOAD THE FILE FROM DISK
window.resolveLocalFileSystemURL(
result[0],
function (fileEntry) {
fileEntry.file(function (file) {
reader.readAsDataURL(file)
})
},
function (err) {
}
)
from cordova-plugin-camera-preview.
I'd like a similar feature because I need to send the base64 through a webservice
from cordova-plugin-camera-preview.
I thought it could be a good idea to use cordova-plugin-file plugin to read file and get base64
from cordova-plugin-camera-preview.
Yes, you should use the cordova-file in order to read the picture file and them get the base64.
Please, refer to this documentation: http://docs.phonegap.com/en/edge/cordova_file_file.md.html
readAsDataURL: Read file and return data as a base64-encoded data URL.
from cordova-plugin-camera-preview.
Would you be able to add an example of using the file documentation please? (or point to a more recent version). I am trying to use the described example but can't work out how to load the file path in the filereader
from cordova-plugin-camera-preview.
@rphansen91 Your code didn't work to me, reader.onloadend never trigger.
I tried as well with this and doesn't work either:
readFile(fileEntry) { // picture
fileEntry.file(function(file) {
var reader = new FileReader();
reader.onloadend = function() {
console.log("Successful file read: " + this.result);
displayFileData(fileEntry.fullPath + ": " + this.result);
};
reader.readAsText(file);
}, that.onErrorReadFile);
}
Uncaught TypeError: Object /data/data/com.drodriguez.foodApp/files/camerapreview_16_06_2016_0918_39_original.jpg has no method 'file'
from cordova-plugin-camera-preview.
Related Issues (20)
- Get color of touched pixel from camera preview HOT 1
- takeSnapshot return blank image HOT 1
- camera is taking entire screen height and flip and close,capture buttons are not visible in native device,Please let me know if anyone has solution for this,z index is already given same as in the code HOT 2
- is platform windows supported ? HOT 3
- is platform browser supported ? HOT 1
- error building with xcode 13.4.1 HOT 6
- How to add barcode scanning ability using another plugin?
- takePicture error only on Android 9
- How to disallow Screenshot
- Android Studio forces me to set android:exported="true" in AndroidManifest.xml HOT 1
- Image is saved as Base64 regardless of storeToFile setting
- Illegal Access HOT 1
- This plugin doesn't seem to install in Android 13, API 33 HOT 2
- takePicture does not resolve promise on iPhone 15 Pro HOT 4
- AVCaptureStillImageOutput' is deprecated: first deprecated in iOS 10.0 - Use AVCapturePhotoOutput instead.
- iPhone 13 Pro Max autofocus issue on close objects HOT 1
- Documentation wrong for takeSnapshot and takePicture
- Can not perform this action after onSaveInstanceState
- photos Android clearer
- how do i ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-plugin-camera-preview.