I return a payload instead of a form data and I can not retrieve the values with php
I need a post type formdata but I can not figure out how to
$('#send_avatar').click(function(){
var x=document.getElementById("x").value;
var y=document.getElementById("y").value;
var w=document.getElementById("w").value;
var h=document.getElementById("h").value;
var fd = new FormData();
//fd = 'x=' + x + '&y=' + y + '&w=' + w + '&h=' + h ;
fd.append('file', $('#uploadImage')[0].files[0]);
fd.append('x', x);
fd.append('y', y);
fd.append('w', w);
fd.append('h', h);
$(".ris").html("");
//dataString.append("image", immagine);
$.ajax({
type: "POST",
url: "funzioni/upload_avatar.php",
data: fd,
async: false,
cache: false,
contentType: "X-Requested-With:XMLHttpRequest",
processData: false,
success: function(response){
$(".ris").html(response);
}
});
});
How can I do it?