cURL / Mailing Lists / curl-library / Single Mail

curl-library

Help about post a big file to a url via http

From: zsq <sq_zheng_at_hotmail.com>
Date: Fri, 11 Jul 2003 16:52:03 +0800

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