Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

240
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!