cURL / Mailing Lists / curl-library / Single Mail

curl-library

Multipart form trouble

From: Oliver Maylen <oliver_maylen_at_hotmail.co.uk>
Date: Mon, 7 Sep 2009 21:48:46 +0000

I am trying to implement the use of curl in a script I am writing which involved uploading a file in a multipart form. Here is the command I am using as I expected it to be from reading the tutorials:

First we have to log into the site:

curl -H 'User-agent: Mozilla/5.0' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Referer: http://www.my-site.org/login.php' -b cookies www.my-site.org -c cookies www.my-site.org -F username=myusername -F password=mypassword www.my-site.org/takelogin.php

Then I wish to upload using a multipart form:

curl -H 'User-agent: Mozilla/5.0' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Referer: http://www.my-site.org/upload.php' -b cookies www.torrentvault.org -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 "name" and "descr" fields are blank for the purpose of my usage which is fine. I followed the curl tutorial and downloaded the form page, changed "post" to "get" so I could check what the browser URL was to make sure I had all the form data. Here it is for reference:

MAX_FILE_SIZE=1000000&file=filename.zip&name=&nfo=uploaded.nfo&color=0&font=0&size=0&descr=&type=42

As far as I can tell, it's all there. But when I try and upload it fails every time giveing me an error message of "Missing form data". As you can see I have put some header info in but still no luck. The initial login/auth is successful, any help on the issue would be gratefully received.

Regards,

Oli

_________________________________________________________________
View your other email accounts from your Hotmail inbox. Add them now.
http://clk.atdmt.com/UKM/go/167688463/direct/01/
Received on 2009-09-07