To use cURL to send a multipart/form-data request for file uploads, follow the steps below:
Install cURL if it's not already installed on your system.
Open your terminal or command prompt.
Use the following cURL command to send the multipart/form-data request:
curl -X POST -F "file=@/path/to/file.jpg" URL
Replace /path/to/file.jpg
with the actual path to the file you want to upload, and replace URL
with the URL of the server endpoint to which you want to send the request.
-F
options. For example:curl -X POST -F "file=@/path/to/file.jpg" -F "field1=value1" -F "field2=value2" URL
Replace field1=value1
and field2=value2
with the names and values of the additional fields you want to send.
-u
option. For example:curl -X POST -F "file=@/path/to/file.jpg" -u username:password URL
Replace username
and password
with your actual credentials.
The server should process the request and respond accordingly.