cURL / Mailing Lists / curl-library / Single Mail

curl-library

Problems with CURLFORM_FILE?

From: Urban Johansson <urban.johansson_at_aptic.se>
Date: Fri, 20 Oct 2006 12:15:23 +0200

A small problem from a newbie. I'm using version 7.15.1.
 
When trying to upload files to a server the server never recieves the
files....
And strange enough the post-object seems to be left to NULL all the
time,
it looks like cURL never assigns the values to it.
Heres the code:
************************************************************************
*********
CURL *ocurl;
ocurl = curl_easy_init();
if (ocurl) {

        int curl_rc = 0;
        curl_easy_setopt(ocurl, CURLOPT_URL,
"http://localhost/default.php");
        struct curl_httppost *opost=NULL;
        struct curl_httppost *olast=NULL;
        curl_formadd(&opost, &olast, CURLFORM_FILE,
"c:\test.jpg",CURLFORM_END);
        curl_easy_setopt(ocurl, CURLOPT_HTTPPOST, opost);
         
        curl_rc = curl_easy_perform(ocurl);
         
        curl_formfree(opost);
         
        curl_easy_cleanup(ocurl);

}
************************************************************************
*********
 
curl_easy_perform returns 0.
 
 
Could this have anything to with CURLFORM_FILE? In the doc it says that
"It sets the filename field to the basename of the provided filename, it
reads the contents of the
file and passes them as data and sets the content-type if the given file
match one of the
internally known file extensions". But nothing seems to be set.
Am I doing something wrong? (probably....)
 
Regards,
 
Urban Johansson
 
 
Received on 2006-10-20