Read the documentation for curl_formadd
: http://curl.haxx.se/libcurl/c/curl_formadd.html
Specifically, under "Options":
CURLFORM_PTRCONTENTS
followed by a pointer to the contents
of this part, the actual data to send
away. libcurl will use the pointer and
refer to the data in your application,
so you must make sure it remains until
curl no longer needs it. If the data
isn't NUL-terminated, or if you'd like
it to contain zero bytes, you must set
its length with
CURLFORM_CONTENTSLENGTH.
CURLFORM_CONTENTSLENGTH
followed by a long giving the length
of the contents. Note that for
CURLFORM_STREAM contents, this option
is mandatory.
So instead of
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "send",
CURLFORM_FILE, "nowy.jpg",
CURLFORM_END);
You'd want something like
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "send",
CURLFORM_PTRCONTENTS, p_jpg_data,
CURLFORM_CONTENTSLENGTH, jpg_data_len,
CURLFORM_END);
I'm assuming you know how to create p_jpg_data
and read the data into it, or do you need that explained?