cURL / Mailing Lists / curl-library / Single Mail


How to post file to url via HTTP

From: zsq <>
Date: Fri, 11 Jul 2003 15:29:22 +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;

               CURLFORM_COPYNAME, "file",
               CURLFORM_COPYCONTENTS, "c:\\123.doc",

 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);

Thank you!

This SF.Net email sponsored by: Parasoft
Error proof Web apps, automate testing & more.
Download & eval WebKing and get a free book.
Received on 2003-07-11