How can I upload a file named yes, this filename has a comma.txt
with the cli curl
?
You would normally do this to upload a file with curl
:
curl --progress-bar -F "fileUpload=@filename.txt"
However curl
interprets commas as multiple files to upload, so this will not work:
curl --progress-bar -F "fileUpload=@yes, this filename has a comma.txt"
How can I escape the filename?
I already found a workaround by creating a temporary symlink to the original file and pass that to curl. However the problem is that the filename that curl
sends to the server is the filename of the symlink, not the original file.
Best Answer
You have not said what OS you are using. The following solutions work for Linux (not only for
curl
but most kinds of escaping:Put the file name in quotes (you need to escape them as well):
Escape the comma