curl-library
Re: Help about post a big file to a url via http
Date: Fri, 11 Jul 2003 08:15:06 -0400
You need a different for of the curl_formadd call. Try this:
curl_formadd(&formpost,
&lastptr,
CURLFORM_FILENAME, "file",
CURLFORM_FILE, "c:\\123.doc",
CURLFORM_END);
On Friday, July 11, 2003, at 04:52 AM, zsq wrote:
> Hi, i'm using libcurl presently. That is a great work! Thank you for
> your excellent job!
> I encounter a problem when i wanna to post a local file to a Http url.
> The following is the code: By the way i use curl-library 7.10.5 and
> VC++ on Windows
>
> CURL *curl;
> CURLcode res;
>
> struct HttpPost *formpost=NULL;
> struct HttpPost *lastptr=NULL;
> res = curl_global_init(CURL_GLOBAL_ALL);
> if(res != CURLE_OK)
> return res;
>
> curl_formadd(&formpost,
> &lastptr,
> CURLFORM_COPYNAME, "file",
> CURLFORM_COPYCONTENTS, "c:\\123.doc",
> CURLFORM_END);
>
>
> curl = curl_easy_init();
>
> if(curl) {
> res = curl_easy_setopt(curl, CURLOPT_URL, url);
> res = curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
> res = curl_easy_perform(curl);
> curl_easy_cleanup(curl);
> curl_formfree(formpost);
> }
> curl_global_cleanup();
>
> Thank you!
>
-------------------------------------------------------
This SF.Net email sponsored by: Parasoft
Error proof Web apps, automate testing & more.
Download & eval WebKing and get a free book.
www.parasoft.com/bulletproofapps1
Received on 2003-07-11