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

235
Views
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 answers
Answer question

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 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!