| 
 | 
 
The following code can upload the specified file in the specified directory to the specified directory on an HTTP server 
curl_global_init (CURL_GLOBAL_ALL); 
curl_formadd (&formpost,&lastptr, CURLFORM_COPYNAME, "file_name", CURLFORM_FILE, filepath, CURLFORM_END); 
if (httpflag == 0) { 
curl_formadd (&formpost,&lastptr, CURLFORM_COPYNAME, "buttom2", CURLFORM_COPYCONTENTS, "UPLOAD", CURLFORM_END); 
} else if (httpflag == 1) { 
curl_formadd (&formpost,&lastptr, CURLFORM_COPYNAME, "buttom1", CURLFORM_COPYCONTENTS, "UPLOAD", CURLFORM_END); 
} 
timevalue = conf_get_prop ("General", "UploadTimeout"); 
if (timevalue == NULL) { 
TR_MALLOC (timevalue, 10); 
TR_STRNCPY (timevalue, DEF_UPLOAD_TIME, 10); 
} 
curl = curl_easy_init (); 
if (curl) { 
// curl_easy_setopt (curl, CURLOPT_HEADER, TRUE); 
curl_easy_setopt (curl, CURLOPT_URL, url); 
curl_easy_setopt (curl, CURLOPT_USERPWD, userpwd); 
curl_easy_setopt (curl, CURLOPT_POST, TRUE); 
curl_easy_setopt (curl, CURLOPT_TIMEOUT, atoi (timevalue)); 
curl_easy_setopt (curl, CURLOPT_HTTPPOST, formpost); 
res = curl_easy_perform (curl); 
} 
 
 
How to use Libcurl to realize the download of the specified file on the HTTP server to the specified directory? Urgent !!! Thank you |   
 
 
 
 |