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

152
Views
Display image that i choose before to click in update with symfony 5.4

I need to edit a class named "classroom" which has the attributes id, name, teacher and image. So far uploading and editing the images in the database is working, but in the edit page I would like to display the new image before clicking the update button. I have done something but nothing works if anyone can help me please.

The code of the view edit :


{% block title %}Edit Classe{% endblock %}

{% block body %}
    <h1>Edit Classe</h1>
                 {{ form_start(form) }}
                    {{ form_errors(form) }}

                    {{ form_row(form.nom) }}
                    {{ form_row(form.enseignant) }}
                    {{form_row(form.image)}}
            

                    <img id="output" src="{{ asset('img/course/small/'~ classe.image) }}" alt="course" class="card-img card-img-horizontal-lg sh-18 sw-lg-16 h-lg-100">

                        
                    {{ form_row(form.cours) }}
                {{ include('classe/_form.html.twig', {'button_label': 'Update'}) }}
        
                {{ form_end(form) }}

<script>
function file_changed(){
    var selectedFile = document.getElementById('input').files[0];
  var img = document.getElementById('img')

  var reader = new FileReader();
  reader.onload = function(){
  img.src = this.result}
  reader.readAsDataURL(selectedFile);
 }
</script>
     
    
{% endblock %}
about 4 years ago · Juan Pablo Isaza
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!