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

81
Views
How to display an image immediately after user selects it from their file explorer?

I am currently working on creating a form that takes in a .png file and stores it in a database. Is there a way to display the image on the frontend immediately after the user selects the .png from their file explorer without reloading the page or submitting the form? i.e., can the image be displayed immediately following selection without any backend interaction?

Boiling it down to the simplest components, I'm looking for something where the image is displayed in a div above the image input:

<div id="SelectedImage">Selected Image:</div>

<input id="pngFile" type="file" />

Thanks in advance.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Hello you can do it with jQuery, for example:

function img_pathUrl(input){
        $('#img')[0].src = (window.URL ? URL : webkitURL).createObjectURL(input.files[0]);
    }
#img {
  background: #ddd;
  width:100px;
  height: 90px;
  display: block;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<img id="img">
<br>
<input type="file" id="img_file" name="img_file" onChange="img_pathUrl(this);">

Adapt it to your needs.

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!