multipart/form-data
10 May 2025 (Updated 18 May 2025)
On this page
What is multipart/form-data
?
multipart/form-data
is a content type used in HTTP requests for sending binary data like files alongside regular form fields.
For example, submitting the following HTML form:

Can result in the following HTTP request:
POST /submit.php HTTP/1.1
Host: sajad.local:8000
Connection: keep-alive
Content-Length: 417374
Origin: http://sajad.local:8000
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary3hPnbQmTWdhIF3aw
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36
------WebKitFormBoundary3hPnbQmTWdhIF3aw
Content-Disposition: form-data; name="name"
Sajad
------WebKitFormBoundary3hPnbQmTWdhIF3aw
Content-Disposition: form-data; name="age"
31
------WebKitFormBoundary3hPnbQmTWdhIF3aw
Content-Disposition: form-data; name="photo"; filename="My picture.png"
Content-Type: image/png
�PNG
IHDR {C� cHRM z& �� � �� u0 �` :� p��Q< bKGD � � ����� pHYs !7 !8���� tIME� ($w � IDATxڄ�G�%Y��b�Rw���_�M�6�
��Loz~�L7�̯ò[�"�z�@�*�fVU�Ȍ�����,���s�z��D���5;Dϧ\��������HDD$���CD�_�����zz'?)^ADD@ A!� A!���sRI!$��CQ ���-��(P
� <�?"��x������O<�p����l������1ĵ����r !��{/����G����!��_'�{ty�_?!! yo�@�!��!�(�6&]���
�6�o$�te�u������gƯ�Hb����z�z�.�����t�!�Hrq�⊥S�����>,����!�9I���<rH�����u@D^>� ���(����d* k�B)����{�WJ!��>�
------WebKitFormBoundary3hPnbQmTWdhIF3aw--
Note that I have removed over two thousand lines of the actual HTTP request from above to shorten the example. In reality, a HTTP multipart/form-data
request that contains a file will send the file as binary data in the request so the actual request can be thousands of lines.
Here’s the format of a multipart/form-data
request:

Links
Tagged:
HTTP