This is my javascript
function ajax_post(){
// Create our XMLHttpRequest object
var hr = new XMLHttpRequest();
// Create
The browser sets the correct headers (including the correct multipart boundary indication in the Content-type) if you haven't manually specified anything.
So all you need to do is remove the following line:
hr.setRequestHeader("Content-type", "multipart/form-data");
Otherwise you will need to set the boundary yourself as it is suggested by Ellias Van Ootegem in Uploading a file with XMLHttprequest - Missing boundary in multipart/form-data:
hr.setRequestHeader("Content-type","multipart/form-data; charset=utf-8; boundary=" + Math.random().toString().substr(2));