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.
POSTmethod is commonly used for file uploads.Body > form-datalets you send files and data together.- Set the key type to
Fileto 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
Filetype: Leaving the key type asTextsends the file path as text, not the file content. - Missing
form-dataselection: Usingrawor other body types won't upload files correctly. - Incorrect HTTP method: File uploads usually require
POSTorPUT, notGET.
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
| Step | Action |
|---|---|
| 1 | Set HTTP method to POST |
| 2 | Go to Body tab and select form-data |
| 3 | Add key with the server's expected name |
| 4 | Change key type to File |
| 5 | Choose the file to upload |
| 6 | Send 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.