Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

124
Vistas
Javascript show image src with it's file extension

Hello everyone I used javascript to preview my image before it saves in my database which works perfectly but I want it to show not as blob:url... but I was the image src to also carry the file extension please is there anyway i can make this to work?

Here's my code

<div class="form-group">
       <div class="n_listed" style="margin-top: -10px">
            <br>
          <label for="file" style="cursor: pointer;">
             <a>
             <i class="mdi mdi-plus-box-outline"></i>
             Upload Image </a> &nbsp; &nbsp;
             &nbsp; &nbsp;</label><br>
               <input type="file" class="form-control @error('banner_image') is-invalid @enderror"  accept="image/*" name="banner_image" id="file"  onchange="loadFile(event)">
                @error('banner_image')
                 <span class="invalid-feedback" role="alert">
                  <strong>{{ $message }}</strong>
                 </span>
                 @enderror
               <p><img id="cover" style="max-width: 750px;" src="{{asset('dasharea/img/placeholder.png')}}"/></p>
               <div style="color: #333;font-size: .9em;margin: 10px 0 5px" class="progress_msg">
                      Note: Maximum size of the image should be 10MB
                </div>
                <script>
                  var loadFile = function(event) {
                  // let imgfile = $('#file').val();
                  // var imgext = imgfile.split('.').pop();
                     var image = document.getElementById('cover');
                     image.src = URL.createObjectURL(event.target.files[0]);
                       };
                   </script>
                                                                                                    
                    </div>
                  </div>

Please I really need help on this. I want it to save as blob:http://localhost:8000/6e315126-ef45-4419-a35d-c3dd2eb2eff7.jpg or .png or depending on the file extension instead of just blob:http://localhost:8000/6e315126-ef45-4419-a35d-c3dd2eb2eff7. Because based on validation rules the image cannot save in the database without it's file extension.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda