Tuesday, 3 November 2015

How to make Image to String like Base64 encryption in javcascript ?

<input type="file" onchange="imgLoad()"><br>
<img src="" height="200" alt="Image preview...">

<script>
function imgLoad(){
var p=document.querySelector('img');
var f=document.querySelector('input[type=file]').files[0];
var read=new FileReader();
read.onloadend=function(){
p.src=read.result;
alert(read.result)
}

if(f){
read.readAsDataURL(f);
}

}

</script>

Example....


Image preview...

No comments:

Post a Comment