Img Url From Base 64 Data Javascript
I have base64 data and I need to convert to image src I know the format: document.getElementById('img').setAttribute( 'src', 'data:image/png;base64, stringdatahere' ); But I don't
Solution 1:
Use string concatenation:
document.getElementById('img').setAttribute( 'src', 'data:image/png;base64,' + dataObject.base64 );
Solution 2:
If you have the data in a variable then just
document.getElementById('img').setAttribute( 'src', 'data:image/png;base64,' + dataVariableName );
Post a Comment for "Img Url From Base 64 Data Javascript"