Q:

C libcurl force "Content-Type"

I have the follwing C code with libcurl to upload a file to my webserver, almost ok the only problem I need the upload to be "Content-Type: application/vnd.ms-excel" but it gets "Content-Type: application/octet-stream", tried with headers but now luck. In PHP with curl is easy, I just do curl_setopt($ch, CURLOPT_POSTFIELDS, array("importfile" => "@".$file_path . ";type=application/vnd.ms-excel" and works ok. Any help? Ideas?
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>

int main(int argc, char *argv[])
{
  CURL *curl;
  CURLcode res;

  struct curl_httppost *formpost=NULL;
  struct curl_httppost *lastptr=NULL;
  struct curl_slist *headerlist=NULL;
  static const char buf[] = "Expect:";

  curl_global_init(CURL_GLOBAL_ALL);

  curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "importfile", CURLFORM_FILE, "document.csv", CURLFORM_END);
  curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "action", CURLFORM_COPYCONTENTS, "upload", CURLFORM_END);

  curl = curl_easy_init();
  headerlist = curl_slist_append(headerlist, buf);
  if(curl) {
    curl_easy_setopt(curl, CURLOPT_URL, "http://www.myhost.com/upload/upload.php");
    if ( (argc == 2) && (!strcmp(argv[1], "noexpectheader")) )
      curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
    curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);

    res = curl_easy_perform(curl);
    if(res != CURLE_OK)
      fprintf(stderr, "curl_easy_perform() failed: %s\n",
              curl_easy_strerror(res));

    curl_easy_cleanup(curl);

    curl_formfree(formpost);
    curl_slist_free_all (headerlist);
  }
  return 0;
}

Tried to add in the HEADER as "Content-Type: application/vnd.ms-excel" but is not right, I get:
Content-Type: application/vnd.ms-excel

in the headers but I need to have:
------WebbbbFormBoundaryXaI1UTNwqAyKWvLT
Content-Disposition: form-data; name="importfile"; filename="document.csv"
Content-Type: application/vnd.ms-excel

instead I get:
------WebbbbFormBoundaryXaI1UTNwqAyKWvLT
Content-Disposition: form-data; name="importfile"; filename="document.csv"
Content-Type: application/octet-stream

Thanks for help guys, answer is:
curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "importfile", CURLFORM_FILE, "document.csv", CURLFORM_CONTENTTYPE, "application/vnd.ms-excel", CURLFORM_END);

A:

You're looking for curl_formadd's option CURLFORM_CONTENTTYPE.

