curl-library
Re: specify form name in POST
Date: Tue, 26 Feb 2008 11:16:31 -0800
Hi,
I found the problem:
CURLFORM_COPYNAME, "uploaded_data",
should have been:
CURLFORM_COPYNAME, "my_form[uploaded_data]",
I thought that you need to somehow "wrap" the form in the name "my_form".
Anyway...
Thanks again,
Tiberiu
On Tue, Feb 26, 2008 at 12:00 AM, Tiberiu Motoc <tiberiu.motoc_at_gmail.com>
wrote:
> Hi Daniel,
>
> Thanks for the reply. I have on more question. What is the code for this
> command line:
> curl -F "my_form[uploaded_data]=@index.xml"
>
> is it equivalent to(?):
>
> curl_formadd( &formpost,
> &lastptr,
> CURLFORM_COPYNAME, "uploaded_data",
> CURLFORM_FILE, "/home/motoct/dev/junk/index.xml",
> CURLFORM_END);
>
> curl_easy_setopt( curl_handle,
> CURLOPT_HTTPPOST,
> formpost);
>
> curl_easy_perform(curl_handle);
>
> The two are not exactly equivalent. My web server shows the two requests
> are different.
>
> Tiberiu
>
>
> On Mon, Feb 25, 2008 at 4:44 AM, Daniel Stenberg <daniel_at_haxx.se> wrote:
>
> > On Mon, 25 Feb 2008, Tiberiu Motoc wrote:
> >
> > > I was wondering if it is possible to specify the form name in a POST
> > > request. I know you can do that using the command line:
> > > curl -F "my_form[uploaded_data]=@index.xml"
> > > http://localhost:3000/indexes.xml
> > > , so you should be able to do it from the code.
> > >
> > > (the index page has a form with name="my_form")
> >
> > The name of the form is not passed along with that, and in fact the name
> > of
> > the form is never passed along to the server since it is used only for
> > browser-local stuff.
> >
> > The name of the input field is however relevant, possible to send and is
> > what
> > you send in the above example.
> >
> > And you do that with curl_formadd() of course.
> >
> > --
> > Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
> >
>
>
Received on 2008-02-26