$(() => {
const imagesPreview = (input, container) => {
if (input.files) {
for (const file of input.files) {
const reader = new FileReader();
reader.onload = e => {
$($.parseHTML('<img>')).attr('src', e.target.result).appendTo(container);
$($.parseHTML('<div>')).text(file.name).appendTo(container);
}
reader.readAsDataURL(file);
}
}
};
$('#gallery-photo-add').on('change', e => imagesPreview(e.currentTarget, 'div.gallery'));
});