Bash

Multipart File Upload via cURL

admin by @admin ADMIN
5h ago
May 31, 2026
Public
0 0 up · 0 down Sign in to vote
Upload one or more files using -F. Optional extra form fields go through the same flag — quote carefully to preserve spaces.
Bash
Raw
# Single file
curl -F "avatar=@/tmp/me.jpg" \
     -F "user_id=42" \
     -H "Authorization: Bearer $TOKEN" \
     https://api.example.com/users/42/avatar

# Multiple files at once
curl -F "files[]=@photo1.jpg" \
     -F "files[]=@photo2.jpg" \
     -F "album=Vacation" \
     https://api.example.com/photos

# Specify content type and filename
curl -F "file=@/tmp/data.json;type=application/json;filename=report.json" \
     https://api.example.com/upload
Tags

Save your own code snippets

Create a free account and build your private vault. Share publicly whenever you want.