<script>
$scope. Imgchange = function (Element) {
if (!element.files[0]) {
Console.log ("No pictures selected! ");
Return
}
$scope. $apply (function (scope) {
var photofile = element.files[0];
var reader = new FileReader ();
Reader.onload = function (e) {
var prev_img = document.getElementById ("Face");
PREV_IMG.SRC = E.target.result;
var bufferdata=prev_img.src.replace (/^data:image\/\w+;base64,/, "");
$scope. imagesrc= Btoa (Bufferdata);
$scope. imagesrc=prev_img.src
function uint8tostring (u8a) {
var CHUNK_SZ = 0x8000;
var c = [];
for (var i=0; i < u8a.length; i+=chunk_sz) {
C.push (String.fromCharCode.apply (null, U8a.subarray (i, I+CHUNK_SZ)));
}
Return C.join ("");
}
$scope. u8_2 = new Uint8array (Atob ($scope. imagesrc). Split (""). Map (function (c) {
Return c.charcodeat (0); });//This is used to save data
$scope. b64encoded = Btoa (uint8tostring ($scope. u8_2));
$scope. image= Window.atob ($scope. b64encoded);//This is used for page previews
};
Reader.readasdataurl (Photofile);
});
};
</script>
<ion-item class= "Item-input Item-stacked-label" >
<input onchange= "Angular.element (This). Scope (). Imgchange (This)" type= "file" multiple accept= "image/jpg,image/ Jpeg,image/png "style=" width:100%; height:251px; Display:block; Border:none;opacity:0;position:absolute; "/>
</ion-item>
Angular image upload function