cURL / Mailing Lists / curl-users / Single Mail

curl-users

Multipart form trouble

From: Oliver Maylen <oliver_maylen_at_hotmail.co.uk>
Date: Wed, 9 Sep 2009 22:21:52 +0000

Hi there,

I am writing a script with which I wish to implement the use of cURL to first login to a site and then using a multipart form upload two files and pass other data. However I am getting errors and I can not see where I am going wrong. Any input gratefully received.

Details:

OS is 32bit Linux,

1.) Firstly the login page:

curl -A 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5)' -H 'Content-Type: application/x-www-form-urlencoded' -b cookies.txt -c cookies.txt -d "username=myusername&password=mypassword" www.my-site.org/takelogin.php

The above works fine and logs in, saving the cookies....

2.) POST multipart form (note: includes 2 file uploads):

curl -A 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5)' -H 'Content-Type: multipart/form-data' -H 'Referer: http://www.my-site.org/upload.php' -b cookies.txt -c cookies.txt -F "MAX_FILE_SIZE=1000000" -F "file=@/path/to/filename.zip" -F "name=" -F "nfo=@/path/to/nfo.nfo" -F "color=0" -F "font=0" -F "size=0" -F "descr=" -F "type=42" www.my-site.org/takeupload.php

The first command logs in successfully and saves the cookies, but the above multipart post fails, with the error message, "Upload failed! Missing form data!"

I'm sure I am just using the commands incorrectly, so any guidance would be a real help. Verbose output shows the following:

* About to connect() to www.my-site.org port 80 (#0)
* Trying 11.22.33.44... connected
* Connected to www.my-site.org (11.22.33.44) port 80 (#0)
* failed creating formpost data
* Connection #0 to host www.my-site.org left intact
curl: (26) failed creating formpost data
* Closing connection #0

Regards,

Oliver

_________________________________________________________________
Save time by using Hotmail to access your other email accounts.
http://clk.atdmt.com/UKM/go/167688463/direct/01/

-------------------------------------------------------------------
List admin: http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2009-09-10