0
0
PostmanHow-ToBeginner ยท 4 min read

How to Upload File in Postman: Step-by-Step Guide

To upload a file in Postman, select the POST method, go to the Body tab, choose form-data, then add a key with type File and select your file. Send the request to upload the file to the server endpoint.
๐Ÿ“

Syntax

In Postman, file upload is done using the form-data body type. You add a key with the type set to File and select the file to upload. The key name should match the server's expected parameter name.

  • POST method is commonly used for file uploads.
  • Body > form-data lets you send files and data together.
  • Set the key type to File to attach a file.
http
POST /upload HTTP/1.1
Host: example.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary

------WebKitFormBoundary
Content-Disposition: form-data; name="file"; filename="example.txt"
Content-Type: text/plain

(file content here)
------WebKitFormBoundary--
๐Ÿ’ป

Example

This example shows how to upload a file named sample.txt to an API endpoint https://api.example.com/upload using Postman.

text
POST https://api.example.com/upload

Body tab:
- Select <strong>form-data</strong>
- Add key: <code>file</code>
- Change type from <code>Text</code> to <code>File</code>
- Choose file: <code>sample.txt</code>

Headers are set automatically by Postman.
Output
HTTP/1.1 200 OK { "message": "File uploaded successfully", "filename": "sample.txt" }
โš ๏ธ

Common Pitfalls

  • Wrong key name: The server expects a specific key name for the file; using a different name causes failure.
  • Not selecting File type: Leaving the key type as Text sends the file path as text, not the file content.
  • Missing form-data selection: Using raw or other body types won't upload files correctly.
  • Incorrect HTTP method: File uploads usually require POST or PUT, not GET.
text
Wrong way:
Body tab: form-data
Key: file (type Text)
Value: C:\\Users\\file.txt

Right way:
Body tab: form-data
Key: file (type File)
Select the actual file from disk
๐Ÿ“Š

Quick Reference

StepAction
1Set HTTP method to POST
2Go to Body tab and select form-data
3Add key with the server's expected name
4Change key type to File
5Choose the file to upload
6Send the request
โœ…

Key Takeaways

Always use the POST method and form-data body type to upload files in Postman.
Set the key type to File and select the actual file to upload, not just enter the file path.
Match the key name exactly as the server expects to avoid upload errors.
Headers for multipart/form-data are set automatically by Postman.
Avoid using raw or other body types for file uploads.