Hi i have problem with ajax and formData
var formData = new FormData($('form')[0]);
formData.append('image', $('inputFile')[0].files[0]);
$.ajax({
type: "POST",
url: url,
data: formData,
processData: false,
contentType: false,
success: function(data) {
console.log(data);
}
});
in PHP i just print_r $_POST and $_FILES and it's empty.
HTML
<form onsubmit="return false;" enctype="multipart/data-form" method="POST">
<input type="file" id="inputFile" />
</form>
UPDATE
Headers are sent, request payload has the content but still $_POST or $_FILES are emptry.
var file_data = $("#inputFile").prop("files")[0];
var formData = new FormData();
formData.append("image", file_data);
$.ajax({
type: 'post',
cache: false,
processData: false,
url: url,
data: ajaxData,
error: function (result) {},
success: function (result) {}
});
You can get this as $_FILES['image'] in php code