I want to upload a file in background using JavaScript and XMLHttpRequest
but my page "upload.php" receive empty $_POST and $_FILES.
var formData = new FormData();
formData.append("file", file);
xhr.open("POST", "upload.php", true);
xhr.setRequestHeader('Cache-Control','no-cache');
xhr.setRequestHeader("Content-Type","multipart/form-data");
xhr.send(formData);
I have try a lot a things in xhr.setRequestHeader()
but nothings work.