5
I’m trying to upload files imagens
, but when I’m clicking on X
of the photo Preview, it is only closing the Preview, but it is still selected. How can I do for when click on x
, also take that image from the list?
My JS code just below.
<script>
window.onload = function(){
//Check File API support
if(window.File && window.FileList && window.FileReader)
{
var filesInput = document.getElementById("files");
filesInput.addEventListener("change", function(event){
var files = event.target.files; //FileList object
var output = document.getElementById("result");
for(var i = 0; i< files.length; i++)
{
var file = files[i];
//Only pics
if(!file.type.match('image'))
continue;
var picReader = new FileReader();
picReader.addEventListener("load",function(event){
var picFile = event.target;
var div = document.createElement("div");
div.innerHTML = "<img class='thumbnail' src='" + picFile.result + "'" +
"title='" + picFile.name + "'/> <a href='#' class='remove_pict del'><i class=\"icon-remove\"></i></a>";
output.insertBefore(div,null);
div.children[1].addEventListener("click", function(event){
div.parentNode.removeChild(div);
});
});
//Read the image
picReader.readAsDataURL(file);
}
});
}
else
{
console.log("Your browser does not support File API");
}
}
</script>
Have you tested with
files.value = '';
?– Sergio
I didn’t test it, but how would it look ? @Sergio
– Renan Rodrigues
Renan, which list you say should be taken too?
– falsarella
?? does not understand your question.
– Renan Rodrigues
Of your question: How can I do it when I click on
x
that image of list? - Which list you mean? (Remark outside the scope: When replying to a comment, put @nameDoUsuario, so it is notified of its replica: in my case it would be @falsarella).– falsarella
Is java or javascript?
– Guilherme Nascimento
javscript. @Guilhermenascimento porem ja solucionei.
– Renan Rodrigues
Renan then formulate a response, it can be useful to other users.
– Guilherme Nascimento
Okay I’ll formulate, as soon as I get back to working on this project.
– Renan Rodrigues