Skip to content

Instantly share code, notes, and snippets.

@myndzi
Last active August 29, 2015 14:03
Show Gist options
  • Save myndzi/75bd45ef8b88ff3467e4 to your computer and use it in GitHub Desktop.
Save myndzi/75bd45ef8b88ff3467e4 to your computer and use it in GitHub Desktop.
Multipart/form-data POST
HTML:
<form action="/api/thing" method="post" enctype="multipart/form-data">
<input name="caption">
<input type="file" name="file">
<input type="submit" value="Submit">
</form>
Request:
POST /api/thing HTTP/1.1
Content-Type: multipart/form-data; boundary=--foo
Content-Length: 12345
--foo
Content-Disposition: form-data; name="caption"
Summer vacation
--foo
Content-Disposition: form-data; name="image1"; filename="GrandCanyon.jpg"
Content-Type: image/jpeg
(Binary data)
--foo--
POST /api/thing HTTP/1.1
Content-Type: multipart/form-data; boundary=--foo
Content-Length: 12345
--foo
Content-Disposition: form-data; name="FooModel"
Content-Type: application/json
{"json":"data"}
--foo
Content-Disposition: form-data; name="BarModel"
Content-Type: application/json
{"json":"data"}
--foo--
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment