/ Published in: JavaScript

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET",url,false); xmlhttp.overrideMimeType('text/plain; charset=x-user-defined'); xmlhttp.send(); var data = ''; for ( var i = 0; i < xmlhttp.responseText.length; i++ ) data += String.fromCharCode( ( xmlhttp.responseText[ i ].charCodeAt(0) & 0xff ) ); // Convert raw data to base64 data = btoa( data ); var base64src='data:image/jpg;base64,'+data; // change the MIME type according to content
Comments
