HTML: Markup language
CSS: Styling language
JavaScript: Scripting language
Web APIs: Programming interfaces
All web technology
Learn web development
Discover our tools
Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The POST HTTP method sends data to the server. The type of the body of the request is indicated by the Content-Type header.
POST
Content-Type
The difference between PUT and POST is that PUT is idempotent: calling it once is no different from calling it several times successively (there are no side effects). Successive identical POST requests may have additional effects, such as creating the same order several times.
PUT
HTML forms typically send data using POST and this usually results in a change on the server. For HTML forms the format/encoding of the body content is determined by the enctype attribute of the <form> element or the formenctype attribute of the <input> or <button> elements. The encoding may be one of the following:
enctype
<form>
formenctype
<input>
<button>
application/x-www-form-urlencoded
&
=
first-name=Frida&last-name=Kahlo
multipart/form-data
boundary="delimiter12345"
Content-Disposition
text/plain
When the POST request is sent following a fetch() call, or for any other reason than an HTML form, the body can be any type. As described in the HTTP 1.1 specification, POST is designed to allow a uniform method to cover the following functions:
fetch()
POST <request-target>["?"<query>] HTTP/1.1
<request-target>
Identifies the target resource of the request when combined with the information provided in the Host header. This is an absolute path (e.g., /path/to/file.html) in requests to an origin server, and an absolute URL in requests to proxies (e.g., http://www.example.com/path/to/file.html).
Host
/path/to/file.html
http://www.example.com/path/to/file.html
<query>
An optional query component preceded by a question-mark ?. Often used to carry identifying information in the form of key=value pairs.
?
key=value
A form using application/x-www-form-urlencoded content encoding (the default) sends a request where the body contains the form data in key=value pairs, with each pair separated by an & symbol, as shown below:
POST /test HTTP/1.1 Host: example.com Content-Type: application/x-www-form-urlencoded Content-Length: 27 field1=value1&field2=value2
The multipart/form-data encoding is used when a form includes files or a lot of data. This request body delineates each part of the form using a boundary string. An example of a request in this format:
POST /test HTTP/1.1 Host: example.com Content-Type: multipart/form-data;boundary="delimiter12345" --delimiter12345 Content-Disposition: form-data; name="field1" value1 --delimiter12345 Content-Disposition: form-data; name="field2"; filename="example.txt" value2 --delimiter12345--
The Content-Disposition header indicates how the form data should be processed, specifying the field name and filename, if appropriate.
name
filename
Enable JavaScript to view this browser compatibility table.
GET