<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>
<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>
No comments:
Post a Comment