cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Curl and Multiple File Downloads, again

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 26 Oct 2005 15:57:05 +0200 (CEST)

On Wed, 26 Oct 2005, Huntress Gary B NPRI wrote:

> The form consists of many rows. Each row corresponds to a file. If a
> checkbox is selected the file can be downloaded. Otherwise a file can be
> uploaded. The form is declared as:
>
> <form target=_parent action=https://www.foo.bar/pdmnet-bin/cgfiles.sh
> method=post enctype="MULTIPART/FORM-DATA">

So it is a multipart form and thus -F should be used.

> If I use my browser to select 2 files for download, and post the form, this
> is the response I get:

[snip]

> I saved the querystring from a successful post and submitted that using -d
> and -F but I get an application error saying I have not selected a file to
> download.

-d is wrong, -F is right.

> Since I'm fairly sure that my querystring is ok then I'm guessing it's a
> header/cookie issue.

What did LiveHTTPHeaders reveal in that aspect?

> curl -c cookiejar -b cookiejar -F
> "SEXPORT=Copyout&TOOL_NAME=GENERIC_UNIX&RECTYPE=DOCUMENT&RECNAME=TTPR-01.10.04-RR45096%7E15090&RECALT=C&RECVER=110&LASTFILENAME=2220050-6MK14_20134_5212.CSV&XOPAL=XOPAL&STAGROW=EXISTINGFILE&UNIXALIAS=2220031-5-MK14_20004_5021_R2.CSV&ALIAS=2220031-5-MK14_2
> 0004_5021_R2.CSV&SFILEDESC=5021%2C+R2%2C+8-9-05&START_TOOL=Y&SFILEUPLOAD=&UNIXALIAS=2220031-5MK14_20004_5021D1R1.CSV&ALIAS=2220031-5MK14_20004_5021D1R1.CSV&SFILEDESC=5021%2C+D1R1%2C+8-9-05&START_TOOL=Y&SFILEUPLOAD=&UNIXALIAS=2220051-7_20043_5193.CSV&ALIAS
> =2220051-7_20043_5193.CSV&SFILEDESC=5193%2C+8%2F2%2F05&START_TOOL=Y&SFILEUPLOAD="
> "https://www.foo.bar/pdmnet-bin/cgfiles.sh"

I very much doubt that is a query string that your browser would send for a
form like that. A multipart formpost form is quite different from an ordinary
form, and thus each separate field must be sent with a separate -F use to
create the full multipart post.

Again, compare with your LiveHTTPHeaders output.

> I have no problems using curl with any other page on this site (login,
> search, view, etc). I'm unclear what the target=_parent indicates in the
> form tag, this page has no frames.

The 'target' attribute has no effect on the POST anyway, it is just a hint for
the browser about where to output.

> Even though I have not reached the point where I get a successful response,
> I'm wondering if/how curl can handle the multiple Content-disposition:
> attachment; portions of the response. Will curl be able to save the
> individual files from the response?

No, it will not. But you could easily write up a script using your favourite
language that does, judging from the simple mime-style separators.

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2005-10-26