To upload a file using cURL, you can use the -F
option along with the --form
flag. This allows you to specify a file to upload. Here's an example command:
curl -X POST -F "file=@/path/to/file.txt" https://example.com/upload
In this command, replace /path/to/file.txt
with the actual path of the file you want to upload. https://example.com/upload
should be replaced with the URL of the upload endpoint you want to use.
You can also add additional form fields if required. For example, to upload a file and include a title field, you can use:
curl -X POST -F "file=@/path/to/file.txt" -F "title=My File" https://example.com/upload
Note that the specific syntax may vary depending on your operating system and shell.