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