Loading…
Warp is now open-source Learn more
Loading…
To upload a file with curl using the HTTP POST method, you can use the -F flag (short for --form) with the following syntax:
$ curl -F "<form_field>=@<local_file_path>"<upload_url>Where:
For example:
$ curl -F "file=@mydocument.pdf" https://example.com/uploadThis command sends an HTTP POST request to https://example.com/upload with a form field named file containing the contents of the file mydocument.pdf, while setting the Content-Type header to multipart/form-data.
Note that this method is typically used for uploading files via HTTP or HTTPS, and not for FTP or SFTP transfers, which are covered below.
You can learn more about cURL with our other articles on how to send HTTP POST requests with cURL and how to set HTTP headers with cURL.
If you’re using Warp as your terminal, you can easily retrieve this command using the Warp AI Command Suggestions feature:

Entering curl upload file in the AI Command Suggestions will prompt a curl command that can then quickly be inserted into your shell by doing CMD+ENTER.
To upload a file using the HTTP PUT method, you can use the curl command with the -T flag (short for --upload-file) as follows:
$ curl -T <local_file_path> <upload_url>Where:
For example:
$ curl -T ./mydocument.txt https://example.com/uploadThis command sends an HTTP PUT request to https://example.com/upload with the specified file as the message body of the request.
To upload a file to an FTP server with curl, you can use the following syntax:
$ curl -T <local_file_path> -u <username>:<password>ftp://<ftp_server_url>/<remote_directory>/Where:
For example:
$ curl -T ./mydocument.txt -u myuser:mypassword ftp://ftp.example.com/uploads/Note that you should ensure proper permissions and the existence of the remote directory on the FTP server before proceeding. If security is a concern, consider using secure FTP (SFTP) or other encryption methods, as plain FTP transfers data without encryption.
To upload a file to an SFTP server with curl, you can use this command syntax:
$ curl -T <local_file_path> sftp://<username>@<sftp_server_url>/<remote_directory>/Where:
For example:
$ curl -T ./mydocument.txt sftp://myuser@sftp.example.com/uploads/To upload a file to Artifactory with curl, you can use the following command syntax:
$ curl -u <username>:<password> -T "<local_file_path>" "<artifactory_url>/artifactory/<repository>/<target_path>/<filename>"Where:
For example:
$ curl -u myuser:mypassword -T myartifact.jar "https://artifactory.example.com/artifactory/myrepo/myfolder/myartifact.jar"To upload a file to an Amazon S3 bucket with curl using a presigned URL, you can use the following command syntax:
$ curl --upload-file <local_file_path> <presigned_url>Where:
For example:
$ curl --upload-file ./mydocument.pdf "https://s3.amazonaws.com/mybucket/myobject?AWSAccessKeyId=YOUR_ACCESS_KEY&Expires=EXPIRATION_TIMESTAMP&Signature=SIGNATURE"This command sends a PUT request to the presigned URL with the specified file as the request body.
To upload a file on a Windows operating system with curl, you can use a command similar to the ones provided earlier, with adjustments for Windows file paths.
Here's the general command structure:
$ curl -F "<form_field>=@C:\path\to\local\file" <upload_url>Where:
For example:
$ curl -F "file=@C:\Users\Username\Documents\mydocument.pdf" https://example.com/uploadComments will help make your scripts more readable
Via command line arguments and prompting users for input
Use cURL to send data to a server
Learn how to copy directories and their content in Linux using the cp command with options like -r for recursive copying, -i for interactive mode, and -a for preserving attributes.
Learn how to manually and automatically create and list groups in Linux.
Learn how to output the size of directories and subdirectories in a human-readable format in Linux and macOS using the du command.
Learn how to count files and folders contained in directories and subdirectories in Linux using the ls, find, and wc commands.
Learn how to output the list of open TCP and UDP ports in Linux, as well as their IP addresses and ports using the netstat command.
Learn how to filter and format the content of files and the output of commands in Linux using the awk command.
Learn how to recursively create nested directories using the mkdir command, Bash scripts, and Python scripts.
Learn how to remove local and remote user accounts and associated groups and files in Linux using the userdel and deluser commands.
Learn how to switch between users, log in as another user, and execute commands as another user in Linux.
$ curl -F "<form_field>=@<local_file_path>"<upload_url>$ curl -F "file=@mydocument.pdf" https://example.com/upload$ curl -T <local_file_path> <upload_url>$ curl -T ./mydocument.txt https://example.com/upload$ curl -T <local_file_path> -u <username>:<password>ftp://<ftp_server_url>/<remote_directory>/$ curl -T ./mydocument.txt -u myuser:mypassword ftp://ftp.example.com/uploads/$ curl -T <local_file_path> sftp://<username>@<sftp_server_url>/<remote_directory>/$ curl -T ./mydocument.txt sftp://myuser@sftp.example.com/uploads/$ curl -u <username>:<password> -T "<local_file_path>" "<artifactory_url>/artifactory/<repository>/<target_path>/<filename>"$ curl -u myuser:mypassword -T myartifact.jar "https://artifactory.example.com/artifactory/myrepo/myfolder/myartifact.jar"$ curl --upload-file <local_file_path> <presigned_url>$ curl --upload-file ./mydocument.pdf "https://s3.amazonaws.com/mybucket/myobject?AWSAccessKeyId=YOUR_ACCESS_KEY&Expires=EXPIRATION_TIMESTAMP&Signature=SIGNATURE"$ curl -F "<form_field>=@C:\path\to\local\file" <upload_url>$ curl -F "file=@C:\Users\Username\Documents\mydocument.pdf" https://example.com/upload