cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-library Mailing List Archives

How to post file to url via HTTP

From: zsq <zsq_at_hanwang.com.cn>
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;

 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

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET