File: /var/www/javago-portal-updates/public/assets/js/inputImagePreview.js
$(function () {
let pictureImageTxt =
'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-upload"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="17 8 12 3 7 8"></polyline><line x1="12" y1="3" x2="12" y2="15"></line></svg>';
pictureImageTxt += '<p>' + upload + '</p>';
pictureImageTxt += '<p>(' + validation.image_maxSize + ')</p>';
const inputFile = document.querySelector("#picture__input");
const pictureImage = document.querySelector(".picture__image");
if (!imageFound) {
pictureImage.innerHTML = pictureImageTxt;
}
inputFile.addEventListener("change", function (e) {
const inputTarget = e.target;
const file = inputTarget.files[0];
if (file) {
const reader = new FileReader();
reader.addEventListener("load", function (e) {
const readerTarget = e.target;
const img = document.createElement("img");
img.src = readerTarget.result;
img.classList.add("picture__img");
pictureImage.innerHTML = "";
pictureImage.appendChild(img);
});
reader.readAsDataURL(file);
} else {
pictureImage.innerHTML = pictureImageTxt;
}
});
});