If i won't use div for input field the image will get changed as shown in first image. But, i don't want to display that input field as choose file, so i wrote css for that input field. Can any one help me out from this?
HTML CODE
<div class="row">
<div class="col-md-3">
<div id="changepic">
<i class="fa fa-camera"><input type='file' class="imgInp fileInput" /> Change Photo</i>
</div>
<img class="blah" src="garments.jpg" width="150px" height="150px" alt="your image" />
</div>
<div class="col-md-3">
<div id="changepic">
<i class="fa fa-camera"><input type='file' class="imgInp fileInput" /> Change Photo</i>
</div>
<img class="blah" src="garments.jpg" width="150px" height="150px" alt="your image" />
</div>
<div class="col-md-3">
<div id="changepic">
<i class="fa fa-camera"><input type='file' class="imgInp fileInput" /> Change Photo</i>
</div>
<img class="blah" src="garments.jpg" width="150px" height="150px" alt="your image" />
</div>
<div class="col-md-3">
<div id="changepic">
<i class="fa fa-camera"><input type='file' class="imgInp fileInput" /> Change Photo</i>
</div>
<img class="blah" src="garments.jpg" width="150px" height="150px" alt="your image" />
</div>
</div>
MY CSS
#changepic{
background: rgb(158, 158, 158);
padding: 5px;
width: 140px;
margin: 0 auto;
color: #fff;
text-align: center;
}
.fileInput {
cursor: pointer;
height: 100%;
position: absolute;
top: 0;
right: 0;
z-index: 99;
font-size: 50px;
opacity: 0;
-moz-opacity: 0;
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0);
}
MY SCRIPT
<script>
function readURL() {
var $input = $(this);
if (this.files && this.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$input.next('.blah').attr('src', e.target.result).show();
}
reader.readAsDataURL(this.files[0]);
}
}
$(".imgInp").change(readURL);
</script>

