I am attempting to develop a drag and drop file upload feature without using a traditional form, utilizing JavaScript's FormData. However, I am encountering an issue where PHP does not seem to be receiving the uploaded file. Could there be some missing request headers or another factor that I am overlooking?
JavaScript:
if (item.kind === 'file')
{
const file = item.getAsFile();
const fileFormData = new FormData();
fileFormData.append('file', file);
$.ajax({
url: "backend/uploadFiles.php",
type: 'POST',
data: fileFormData,
cache: false,
contentType: false,
processData: false,
success: function (returndata) {
console.log(returndata);
}
});
PHP:
<?php
var_dump($_POST);
var_dump($_GET);
PHP output:
array(0) {
}
array(0) {
}