javascript - Generate Base64 String with local url of image without input type file -
i trying generate base64 string of local url of image. searched lot didn't got answer. found many example convert base64 string http url of image have local url of image. tried create file object not working. here example tried:
convertfiletodataurlviafilereader(url){ var file = new file([""],url, {type: "image/jpeg"}); let reader = new filereader(); reader.onload = (event) => { var base64 = event.target.result; return base64; }; reader.readasdataurl(file); }
here url absolute path of image : file:\\c:\users\abc\pictures\butterfly.jpg
example not generating base64 image ie returning blank string :
output
data:/
Comments
Post a Comment