Some time ago, I had a question here on the
Some time ago, I had a question here on the
It's quite simple just add the following line:
$("#excluir").click(function(){
$("#fileUpload").val("");
$("#imagem").css("display","none");
$("#excluir").css("display","none");
});
So it will remove the value of the input file and hide the image again.
Complete code:
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$("#imagem").attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#fileUpload").change(function(){
readURL(this);
$("#imagem").css("display","block");
$("#excluir").css("display","block");
});
$("#excluir").click(function(){
$("#fileUpload").val("");
$("#imagem").css("display","none");
$("#excluir").css("display","none");
});
Example: link