JS code
Preview Tell me how to remove the image from the preview (for example, when you click on the cross on the right of the photo)

function myFunc(input) { var files = input.files || input.currentTarget.files; var reader = []; var images = document.getElementById('images'); var name; for (var i in files) { if (files.hasOwnProperty(i)) { name = 'file' + i; reader[i] = new FileReader(); reader[i].readAsDataURL(input.files[i]); images.innerHTML += '<img class="thumb" id="'+ name +'" src="" />'; (function (name) { reader[i].onload = function (e) { console.log(document.getElementById(name)); document.getElementById(name).src = e.target.result; }; })(name); console.log(files[i]); } } } 
  • duck files is an array, delete files[1] necessary element from it, such as delete files[1] - Vasily Barbashev
  • And on the button how to hang up the removal? so that every picture can be removed - Eliot
  • to onclick = pop () or shift () button - Jean-Claude
  • I was wrong, files is an object, and with private properties) - Vasily Barbashev
  • @ Vasily Barbashev, is there another option then? I think you can delete by id - Eliot

0