[英]convert Image to base64 without uploading
i want to save image in localStorage in base 64 format.I know it using Filereader concept like this 我想以base 64格式将图像保存在localStorage中。我使用Filereader这样的概念知道它
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
我只想将现有图像转换为base64。希望有人可以帮忙
Yeah it's kind off possible ;) 是的,这很可能;)
canvas.toDataURL()
(base64 encoded image) canvas.toDataURL()
(以base64编码的图像)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.