Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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):

    curl --progress-bar -F "fileUpload=\"@yes, this filename has a comma.txt\"" 
  • Escape the comma

    curl --progress-bar -F "fileUpload=@yes\, this filename has a comma.txt" 
share|improve this answer
I'm using Mac OS X 10.8.2, only the quoting worked. The one where the comma is escaped, tries to upload a file called "yes" (curl: (26) couldn't open file "yes\"). –  Tyilo May 1 '13 at 16:56
On Mac OSX 10.9.4, I had to put the quotes after the @ like so: curl --progress-bar -F "fileUpload=@\"yes, this filename has a comma.txt\"" –  spyle Sep 23 at 17:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.