2

I'd like to POST a file upload with curl, and choose the filename at request time.

Here's the curl line I have right now, which works to upload the file:

curl --form "upload_file=@content.txt" http://www.website.com/upload

The name of the form field was determined by looking at the request according to Chrome dev tools:

POST /upload HTTP/1.1
Host: website.com
Connection: keep-alive
Content-Length: 2346
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Origin: http://www.website.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryQqVYRMJ741ihKEHQ
DNT: 1
Referer: http://www.website.com/
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8

Request Payload
------WebKitFormBoundaryQqVYRMJ741ihKEHQ
Content-Disposition: form-data; name="upload_file"; filename="content.txt"
Content-Type: text/plain


------WebKitFormBoundaryQqVYRMJ741ihKEHQ--

What I'd like to do is use curl to upload a file on my local filesystem but choose the filename at request time. Is there a way to modify the value of "filename" in the Request Payload?

  • this is probably better suited for stackoverflow not here – Sickest Feb 24 '14 at 19:12
  • Stack Overflow would send it back here. – Kevin Panko Feb 27 '14 at 2:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.