XMLHttpRequest Level 2 adds support for the new FormData interface. FormData objects provide a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using the XMLHttpRequest send() method.

It uses the same format a form would use if the encoding type were set to "multipart/form-data".

For details on how to use the FormData object, see Using FormData objects.


new FormData (optional HTMLFormElement form)


Optional HTML Form Element <form> to send for keys/values. It will also encode file input content.



Appends a key/value pair to the FormData object.

void append(DOMString name, File value, optional DOMString filename);
void append(DOMString name, Blob value, optional DOMString filename);
void append(DOMString name, DOMString value);


The name of the field whose data is contained in value.
The field's value. Can be a Blob, File, or a string, if neither, the value is converted to a string.
Optional The filename reported to the server, when a Blob or File is passed as second paramter. The default filename for Blob objects is "blob".

Note: If you specify a Blob as the data to append to the FormData object, the filename that will be reported to the server in the "Content-Disposition" header used to vary from browser to browser.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 7+ 4.0 (2.0) 10+ 12+ 5+
append with filename (Yes) 22.0 (22.0) ? ? ?
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support 3.0 ? 4.0 (2.0) ?


append with filename ? ? 22.0 (22.0) ? ? ?


Note: XHR in Android 4.0 sends empty content for FormData with blob.

Gecko notes

Prior to Gecko 7.0 (Firefox 7.0 / Thunderbird 7.0 / SeaMonkey 2.4), if you specified a Blob as the data to append to the object, the filename reported in the "Content-Disposition" HTTP header was an empty string; this resulted in errors being reported by some servers. Starting in Gecko 7.0, the filename "blob" is sent.


See also

Document Tags and Contributors

 Contributors to this page: Sheppy
 Last updated by: Sheppy,