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

248
Visualizações
How to add value before file input value on event oninput

I am trying to add text "img/books/" before the image file name in the file upload, to be concatenated and submitted this way the the db: "img/books/imageName.png", but this is not working :/

<script type="text/javascript">
   function addDir()
   {
        const imgDir = 'img/books/'
        document.getElementById('book_img').value =  imgDir +
        document.getElementById('book_img').file.value

   }
</script>

here is html code

<label for="fname">Book Image</label><br>
<input type="file" name="book_img" id="book_img" oninput="addDir()">
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It is not possible to change or set the value of the input file. This is for user safety reasons. However, it is possible to read the file name, associate it with the required address and save it in the input hidden. The backend must be prepared for this.

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