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

236
Vistas
How can I add domain to file when trying to change picture?

I'm trying to upload and change image with jQuery. The upload works fine and the response in ajax seems as expected. In console I got grfx/adam from variable result but in the img-tag I get error 404 not found and it looks like it added domain or something. The src looks like http://localhost:8080/HM/%EF%BB%BF%20grfx/adam.jpg and the result is a broken img-icon. The Javascript function look like this:

<script>
 
function uploadprofilepic() {
    $('#formupload').hide();
    $('#formcrop').show();



// Making the image file object
    var file = $('#newprofilepic').prop("files")[0];

    // Making the form object
    var form = new FormData();

    // Adding the image to the form
    form.append("image", file);
 // Adding the image to the form
    form.append("image", file);

    // The AJAX call
    $.ajax({
        url: "uploadprofilepicture.php",
        type: "POST",
        data:  form,
        contentType: false,
        processData:false,
        success: function(result){
       // byter bild lokalt i hållare
       console.log(result);

       $('#picholder').attr("src", result);
        }
        });

}
</script>

what could possible be wrong? thanks in advance!

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Look like your code is correct but curious about the url http://localhost:8080 is it backend Or front end. If this is frontend URL then you need to check where this image located and set the proper domain URL

I hope you are clear with this.

over 4 years ago · Santiago Trujillo Denunciar
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