Как изменить принятие ссылки
img src принимает только те файлы которые находятся в той же папке с html, вопрос в том как сделать так чтобы img src начал рассчитать с папки C://
let x = document.querySelector(".file")
let y = document.querySelector(".img")
document.querySelector(".file").addEventListener("change",()=>{
y.src = x.value
console.log(x.value)
})
<input type="file" class = "file">
<img class="img">
Ответы (1 шт):
Автор решения: HTMLProgrammer
→ Ссылка
let fileInput = document.querySelector('.file'),
img = document.querySelector('.img');
fileInput.addEventListener('change', e => {
const blob = new Blob([e.target.files[0]]),
url = URL.createObjectURL(blob);
img.src = url;
});
<input type="file" class = "file" accept="image/*">
<img class="img">