How to use CURL to simulate POST request with file upload?

1,230 views
Skip to first unread message

zhangxiao

unread,
Mar 19, 2012, 9:30:47 AM3/19/12
to django-rest-framework
I have a form with one file field and I set it as `form` of my view.

It' works well with the HTML interface when I test in a browser. In
command line I also want to make it work with CURL but no luck.

Does anyone know how to do that? thanks!

Yaniv Aknin

unread,
Mar 19, 2012, 9:42:09 AM3/19/12
to django-res...@googlegroups.com
Assuming the form field is "my_form_field", and the file's name is "/tmp/my_file.jpg" and the URL is http://www.myhost.com/some_path, then:
curl -Fmy_form_field=@/tmp/my_file.jpg http://www.myhost.com/some_path
Reply all
Reply to author
Forward
0 new messages