HTML:
<div id='clock'></div>
<input type='file' id='getval' /><br/><br/>
<div id='clock'></div>
<input type='file' id='getval' /><br/><br/>
CSS:
#clock{
background-image:url('');
background-size:cover;
background-position: center;
height: 250px; width: 250px;
border: 1px solid #bbb;
}
JS:
document.getElementById('getval').addEventListener('change', readURL, true);
function readURL(){
var file = document.getElementById("getval").files[0];
var reader = new FileReader();
reader.onloadend = function(){
document.getElementById('clock').style.backgroundImage = "url(" + reader.result + ")";
}
if(file){
reader.readAsDataURL(file);
}else{
}
}
No comments:
Post a Comment