I have loop buttons to select the image:
@foreach (var item in image)
{
<label class="control-label col-md-7 ">
select image
</label>
<img id="imgworksample" src="~/site/imgworksample/@item.imageName" class="img-
thumbnail" />
<input type="hidden" value="@item.ImageId" />
<input id="img_worksampleupload" name="imgpostupload" type="file" />
<hr />
}
I want the button browser inside the loop to be clicked Select an image and display it?
How to do with jQuery?
this work for one browser button:
<script>
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#imgworksample').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#img_worksampleupload").change(function () {
readURL(this);
});
</script>
