Is it possible to turn an image into a base64 string with these restrictions,
- Image is coming from
<input type="file"/>
- No internet connection
- Mobile Browser
I know I can download an image and convert it using <canvas>
, but is it possible to access the image before it's uploaded? If this is not possible I am going to write a PhoneGap plugin.
Thanks!
Edit-
Got this working using the FileReader API. Here's the relivant code,
var reader = new FileReader();
reader.onload = function(theFile) {
var base64Image = theFile.srcElement.result;
};
// Read in the image file as a data URL.
reader.readAsDataURL(image.fileElement.dom.files[0]);