hello,
I have this JavaScript, so i select multiple images in FileUpload it shows preview of that image in below div.
I want cross button in div so user can remove images from preview also if not need.
<script type="text/javascript">
$(function () {
$('[id*=fuUpload1]').change(function () {
if (typeof (FileReader) != "undefined") {
var dvPreview = $("[id*=dvPreview]");
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 id="dvPreview"></div>
<asp:FileUpload ID="fuUpload1" runat="server" multiple="multiple" />