Erics
Erics

Reputation: 841

How to cURL POST a filename with spaces?

I'm doing a cURL POST request to an API.

One of the form fields is a file, and the desired file name might contain spaces...

If I send the following as the curl option then the file arrives at the other end named simply "HID"

-F [email protected];filename=HID Global member list 12 October 2020.pdf;type=application/pdf

I've tried URL-encoding the filename, and wrapping the filename with quotes. The former gets passed thru without any decoding, and the latter results in a filename of 'HID

Upvotes: 0

Views: 1364

Answers (1)

Andrei Kovrov
Andrei Kovrov

Reputation: 2440

You should use quotes for the entire form, not only for the filename.

Linux/Mac example

 curl -F "[email protected];filename=HID Global member list 12 October 2020.pdf;type=application/pdf" localhost/send-form-url

Upvotes: 1

Related Questions