Read the documentation for curl_formadd : http://curl.haxx.se/libcurl/c/curl_formadd.html
In particular, in the "Parameters" section:
CURLFORM_PTRCONTENTS
followed by a pointer to the contents of this part, the actual data to send is far away. libcurl will use a pointer and access the data in your application, so you need to make sure that it remains until the curl is no longer needed. If the data does not end with NUL or if you want it should contain zero bytes, you must set its length to CURLFORM_CONTENTSLENGTH.
CURLFORM_CONTENTSLENGTH
followed by a long job of content length. Note that for CURLFORM_STREAM, this parameter is required.
So instead
curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "send", CURLFORM_FILE, "nowy.jpg", CURLFORM_END);
You need something like
curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "send", CURLFORM_PTRCONTENTS, p_jpg_data, CURLFORM_CONTENTSLENGTH, jpg_data_len, CURLFORM_END);
I assume that you know how to create p_jpg_data and read the data in it, or do you need to explain this?
source share