this code works fine and show preview of image
problem is when i browse image and select it shows but second time when i browse image and select the first image replaced
i want it should append the image
<script language="javascript" type="text/javascript">
$(function () {
$('[id*=fuUpload1]').change(function () {
if (typeof (FileReader) != "undefined") {
var dvPreview = $("#dvPreview");
dvPreview.html("");
var regex = /^([a-zA-Z0-9\s_\\.\-:])+(.jpg|.jpeg|.gif|.png|.bmp)$/;
$($(this)[0].files).each(function () {
var file = $(this);
if (regex.test(file[0].name.toLowerCase())) {
var reader = new FileReader();
reader.onload = function (e) {
var img = $("<img />");
img.attr("style", "max-height:250px;width: 150px");
img.attr("src", e.target.result);
dvPreview.append(img);
}
reader.readAsDataURL(file[0]);
} else {
alert(file[0].name + " is not a valid image file.");
dvPreview.html("");
return false;
}
});
} else {
alert("This browser does not support HTML5 FileReader.");
}
});
});
</script>
<div class="white-bg shadow">
<h4 class="padding15 no-margin">
Other Images of Product
</h4>
<hr class="no-margin" />
<br />
<label class="file-upload center">
<span class="btn btn-default"><i class="fa fa-image"></i> Select Images</span>
<asp:FileUpload ID="fuUpload1" runat="server" multiple="multiple" />
</label>
<div id="dvPreview">
</div>