Issue
I'm trying to upload a file using command line Curl. Uploading a file (without renaming) works fine:
curl -1 -v -k "sftp://some.domain.com:1234" --user "username:password" -T "my_local_file.txt" 2>&1
But is it possible to specify a different destination filename? I'd like to save the file on the remote server with a different name. Is this possible?
At the moment I'm renaming the file locally; uploading it and then naming it back. Not ideal.
Thanks!
Solution
The -T flag allows you to specify the local file, and you can specify the remote path and filename directly in the URL.
Like so:
curl -1 -v -k "sftp://some.domain.com:1234/remote_path/remote_filename" --user "username:password" -T "local_filename"
This will upload my_local_file.txt from your local system to some_folder on the remote server, the file will be savd as new_remote_file.txt and you won't have to rename the file locally before and after the upload.
Answered By - David Fox Answer Checked By - Willingham (WPSolving Volunteer)