cURL / Mailing Lists / curl-users / Single Mail

curl-users

Problem in chunky parser & Problem uploading file

From: <georg.lippold_at_student.qut.edu.au>
Date: Thu, 29 Jan 2009 13:51:56 +1000 (EST)

Hi,

I am trying to upload files to a web site and wanted to automate the
process using curl. The website code for a file upload basically
consists of the following data:

<form method="post" action="" enctype="multipart/form-data">
<input type="hidden" name="command" value="upload">
<table>
<tr>
<td>filename</td>
<td><input size="40" name="file_1" type="file"></td>
</tr>
<tr>
<td></td>
<td align="right"><input type="submit" name="submit" value="submit">
<input type="submit" name="submit" value="cancel"></td>

(the closing </form> is not in the page but at least Firefox is able to
process the form anyway).

To upload a file I wrote the following curl line:

curl -k -i -b ${COOKIES} -c ${COOKIES_NEW} -L \
  -d "command=upload" \
  -d "name=file_1" \
  -d "filename=test.txt" \
  -T "${HOME}/test.txt" \
  -d "submit=submit" \
  "${URL}" > "${OUTFILE}"

However, whenever I try to run curl like that I get the message

curl: (56) Received problem 2 in the chunky parser

Which does not happen when I try to use

curl -k -i -b ${COOKIES} -c ${COOKIES_NEW} -L \
  -d "command=upload" \
  -d "name=file_1" \
  -d "filename=test.txt" \
  -d "@${HOME}/test.txt" \
  -d "submit=submit" \
  "${URL}" > "${OUTFILE}"

The error in the chunky parser happens in curl 7.19.2 and 7.18.2.

However, in both cases the file I try to upload is not correctly
received by the server. I had a look at LiveHTTPHeaders, and Firefox
sends something like

POST /restricted/upload/bin/main_user.php
-----------------------------13843933292137813252683666129
 Content-Disposition: form-data; name="command"

 upload
 -----------------------------13843933292137813252683666129
 Content-Disposition: form-data; name="file_1"; filename="test.txt"
 Content-Type: text/plain

 95 1.0
 90 1.3
 85 1.7
 80 2.0
 75 2.3
 70 2.7
 65 3.0
 60 3.3
 55 3.7
 50 4.0

 -----------------------------13843933292137813252683666129
 Content-Disposition: form-data; name="submit"

 submit
 -----------------------------13843933292137813252683666129--

I don't know how I would achieve the same result with curl. Does anybody
have an idea?

Thanks & Cheers,

Georg

-------------------------------------------------------------------
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-01-29