cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Set filename in curl_formadd()

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Wed, 12 Oct 2011 00:44:48 -0700

On Tue, Oct 11, 2011 at 09:53:56AM +0200, Schäffer Klaus wrote:
> 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
[...]
>
> 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.

This one is close, but instead of CURLFORM_PTRCONTENTS and CURLFORM_FILENAME,
use CURLFORM_BUFFERPTR, CURLFORM_BUFFER and CURLFORM_BUFFERLENGTH.

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