Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

133
Visualizações
Displaying input image form the user to website

I'm creating a social media application. I got the image input from the user, but I was stuck in displaying the image.

Here is my HTML file

<form id="form">
   <div id="closeForm"><i class="fas fa-window-close"></i></div>
   <label>
     <p>Enter the title:</p>
     <input id="newTitle" placeholder="Art Title" type="text">
   </label>
   <label>
     <p>Select your image:</p>
     <input id="newImg" class="imgInput" accept="image/*" type="file">
   </label>
   <input id = "formBtn" type="button" acc value="Upload">
</form>

This is my JS file

document.getElementById('formBtn').onclick=()=>{
    let newTitle = document.getElementById('newTitle').value;
    let newImg =  document.getElementById('newImg').value;

    let fragment = `
       <img class="art_img" src="${newImg}" alt="" srcset="">
       <p id="title">${newTitle}</p>`;

artContainer.innerHTML+=fragment;
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Use the FileReader object to create a blob and attach it to the element.

Example:

        const reader = new FileReader();
        reader.onload = (e) => {
                imgElm.src = e.target.result;
        };
        // do some checks to make sure its not empty
        reader.readAsDataURL(input.files[0]);
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda