Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

237
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda