Javascript XHR wysyła dane wieloczęściowe / formularze
Próbuję wysłać żądanie typu treści wieloczęściowej / danych formularza:
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
if(xhr.readyState==4){
alert(xhr.responseText);
}
}
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type","multipart/form-data; boundary=---------------------------275932272513031");
xhr.send('-----------------------------275932272513031 Content-Disposition: form-data; name="name"
test
----------------------------275932272513031--');
Następnie w php po prostu wypisuję$_POST
szyk
print_r($_POST);
Ale za każdym razem otrzymuję pustą tablicę. Spodziewam się zobaczyć
Array (
name => "test"
)
Co ja robię źle?