Good day, I am working in asp page for upload image file and preview it by using JavaScript code and I want to add 'remove button' that delete image from (id="imgpreview") and file path ( ID="FileUploadControl")
My code
function showpreview(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
$('#imgpreview').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
function showImage() {
var add = document.createElement('img');
add.src = ''
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table>
<tr>
<td>
<asp:Label ID="Label5" runat="server" Text="Select File to Upload"></asp:Label>
</td>
<td>
<asp:FileUpload ID="FileUpload1" runat="server" onchange="showpreview(this);" />
<asp:Label ID="Label4" class="stylelbl" runat="server" Text="File Type : JPG, Max File Size : 500kb">
</asp:Label>
</td>
</tr>
<tr>
<td>
<img id="imgpreview" alt="" src="" />
</td>
</tr>
</table>