简体   繁体   中英

Using Phonegap download image and want to convert it into base64 in iOS

I am stuck in problem regarding base64.

The situation is - I download image in iPad and getting path of that download image like this :-

{"isFile":true,"isDirectory":false,"name":"testImage.png","fullPath":"/testImage.png","filesystem":"","nativeURL":"file:///var/mobile/Containers/Data/Application/4048F634-D44A-40F8-ACA0-32BC9F401F56/Documents/testImage.png"}

In the above object ,nativeURl from which I am getting image and I am able to append on HTML page, but I want convert it into base64 ,& I am not been able to get till now.

I know somewhere it is possible. I am just making a mistake.
So anybody,expert please help me sort out that issue, if provide example that will be help full in any online editor.

Thanks

Shivam

<div id='mainPostDiv'></div>



    //hello, you need to convert into base64
    // set your data first in localStorage

    var imageData = localStorage.getItem("ImageData");
    var imgPost = document.createElement('img');
    imgPost.setAttribute('id', "imgPost");
    imgPost.src = "data:image/jpeg;base64," + imageData;
    $('#mainPostDiv').append(imgPost);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM