cURL / Mailing Lists / curl-library / Single Mail

curl-library

Set filename in curl_formadd()

From: Schäffer Klaus <Klaus.Schaeffer_at_kapsch.net>
Date: Tue, 11 Oct 2011 09:53:56 +0200

Hi,

I am trying to post an XML file using curl_formadd().The XML file is hold in memory and I don't want to save it to disk. My problem is that the server seems to expect a content-disposition like this: form-data; name="UPLOAD"; filename="THB.xml"\r\n
The filename has to be contained in the content-disposition, otherwise the post is not accepted by the server

My first try was:
curl_formadd(first,
             last,
             CURLFORM_PTRNAME,
             mName.c_str(),
             CURLFORM_PTRCONTENTS,
            mContent.c_str(),
            CURLFORM_CONTENTTYPE,
            mContentType.c_str(),
            CURLFORM_END );

In this case no filename is added so I tried the following:
curl_formadd(first,
             last,
             CURLFORM_PTRNAME,
             mName.c_str(),
             CURLFORM_PTRCONTENTS,
             mContent.c_str(),
             CURLFORM_FILENAME,
             mFilename.c_str(),
             CURLFORM_CONTENTTYPE,
             mContentType.c_str(),
             CURLFORM_END );

But adding CURLFORM_FILENAME was also not succesful.

Can someone please tell me how I can add a filename?

Thanks in advance!

The information contained in this e-mail message is privileged and
confidential and is for the exclusive use of the addressee. The person
who receives this message and who is not the addressee, one of his
employees or an agent entitled to hand it over to the addressee, is
informed that he may not use, disclose or reproduce the contents
thereof, and is kindly asked to notify the sender and delete the e-mail
immediately.

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-10-11