See https://github.com/nervgh/recursive-iterator/wiki/Cookbook-(es6)#to-form-data
Converts json-like object with [File]
, [FileList]
, [Blob]
to [FormData]
object
Object.traverse, Object.getPrototypeOf, Array.prototype.forEach, Array.prototype.map, window.FormData
// convert object to [FormData]
var form = Object.toFormData(object /*{Object|Array}*/);
// send this object
var xhr = new XMLHttpRequest();
xhr.open('POST', '/');
xhr.onload = function() {
alert(xhr.responseText);
};
xhr.send(form);