I am sending post data via XMLHttpRequest:
var xmlHttp=new XMLHttpRequest();
xmlHttp.open(\"POST\", domain, true);
xmlHttp.setRequestHeader(\"Content-type\",
Do not set the Content-Type
header yourself. It will be properly set when .send()
ing the data, including the proper generated boundary, which your manually generated header lacks.
The spec clearly states that .send(FormData)
will use multipart/form-data encoding.
If data is a FormData
Let the request entity body be the result of running the multipart/form-data encoding algorithm with data as form data set and with UTF-8 as the explicit character encoding.
Let mime type be the concatenation of "multipart/form-data;", a U+0020 SPACE character, "boundary=", and the multipart/form-data boundary string generated by the multipart/form-data encoding algorithm.