cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Obtaining response after upload file

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 26 Dec 2005 22:26:53 +0100 (CET)

On Mon, 26 Dec 2005, Danny Su wrote:

> I want to be able to post to a form and use the form to upload a file.
> Afterwards I want to parse the resulting page that is produced. When I use a
> browser (IE or Firefox), after I submit the form I will receive a resulting
> webpage telling me some information. However, when I use libcurl, I get
> nothing. My WRITEFUNCTION doesn't even get invoked!

...

> curl_easy_setopt(curl, CURLOPT_URL, "http://mydomain/");
> curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
> curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
> curl_easy_setopt(curl, CURLOPT_WRITEDATA, &hwnd);
> res = curl_easy_perform(curl);

This looks like the proper approach as far as the CURLOPT_WRITEFUNCTION option
goes. However, many sites do for example redirect the client on the response,
so using followlocation might give you the result you want (and/or it requires
cookies or other stuff you don't pass on in your request). You could use
LiveHTTPHeaders to figure out the differences between the libcurl's and
Firefox's requests and responses.

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