i want to save image in localStorage in base 64 format.I know it using Filereader concept like this
function loadImageFileAsURL()
{
var filesSelected = document.getElementById("inputFileToLoad").files;
if (filesSelected.length > 0)
{
var fileToLoad = filesSelected[0];
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent)
{
alert(fileLoadedEvent);
document.getElementById("textAreaFileContents").innerHTML = fileLoadedEvent.target.result;
};
fileReader.readAsDataURL(fileToLoad);
}
}
but the problem is that i dont want upload any file. I just want to convert existing image into base64.Hope someone can help it
Yeah it's kind off possible ;)
canvas.toDataURL()
(base64 encoded image)
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.