Simple HTTP Post with libCURL
===

ALL,
I tried to search the suggested threads here but to no availability.

I need to send the file to the web server using libCURL POST request.
I am creating the file I'm sending so I know it is exist.
I also have a WireShark installed here so I know what is sent over.

During the debug session I can see that the file has been read and the buffer it is read to is sending out. However, in the WireShark it is all displayed as FF FF FF FF sequence.

And in the end the operation fail with "Error writing the body" error message returning to CURL.

Any idea what might be the problem?

Here is what I tried so far:

1.

    result = curl_formadd( &first, &last, CURLFORM_COPYNAME, "MyFile", 
                           CURLFORM_FILE, (const char *) fileName.c_str(), 
                           CURLFORM_FILENAME, (const char *) fileName.c_str(), 
                           CURLFORM_CONTENTSLENGTH, (long) file.Length(), 
                           CURLFORM_CONTENTTYPE, "image/bitmap", CURLFORM_END );

2.

    result = curl_formadd( &first, &last, CURLFORM_COPYNAME, "MyFile", 
                           CURLFORM_FILENAME, (const char *) fileName.c_str(), 
                           CURLFORM_STREAM, &file, CURLFORM_CONTENTSLENGTH,
                           (long) file.Length(), CURLFORM_CONTENTTYPE, 
                           "image/bitmap", CURLFORM_END );

Then in both cases:

    curl_easy_setopt( handle, CURLOPT_HTTPPOST, first );
    curl_easy_setopt( handle, CURLOPT_POSTFIELDSIZE, file.Length() );

The header in both cases are formed correctly, but the data itself is not sent.

Does anybody have an idea? I feel like I'm missing something very simple...

