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]); } } }
filesis an array,delete files[1]necessary element from it, such asdelete files[1]- Vasily Barbashevfilesis an object, and with private properties) - Vasily Barbashev