John Allard
John Allard

Reputation: 3914

How to post a list of files using Curl

I need to curl multiple files to a website as a list, but I'm having trouble doing so.

I've tried:

curl -F name=fn1 -F [email protected] -F name=fn2 -F [email protected]

But that didn't work, so I tried:

curl -F "files[][email protected]&files[]=fn2.jpg"

But that also didn't work.

I'm trying to get the files on the server side using the python request lib, so something like:

files = request.files.getlist('files[]')

But this call always fails, how do I post a list of files using curl?

Upvotes: 2

Views: 2292

Answers (1)

John Allard
John Allard

Reputation: 3914

I figured it out, the syntax is this :

curl -F files=@$WALLPAPERS/0FYIE5G.jpg \ -F files=@$WALLPAPERS/3GVmZmQ.png http://example.com/upload

And on the receiving end :

files = request.files.getlist('files')

Pretty simple actually.

Upvotes: 3

Related Questions