How can I send an image through ajax?
The code I have is this and for now it only sends text, how could I take the image of <input type="file" id="foto"/>
and send it?
My code:
function updateProfile(){
var name = $("#name").val();
var lastname = $("#lastname").val();
var email = $("#email").val();
var phone = $("#phone").val();
$("#form-updateProfile").submit(function(){
var profileData = {
name : name,
lastname : lastname,
email : email,
phone : phone
}
$.post('php/db_updateProfile.php', profileData, returnValues);
return false;
});
function returnValues(recievedData){
console.log(recievedData);
}
}