cURL / Mailing Lists / curl-library / Single Mail

curl-library

artificial file upload part with curl_formadd()

From: Mohun Biswas <m.biswas_at_cleartool.com>
Date: Tue, 19 Aug 2003 19:16:20 -0400

Hi,

I'm using libcurl (7.10.6) to do a multipart file upload and it works
fine. But now I want one of those parts to be "fake"; in other words it
should look just like every other file upload part except that the
contents do not come from a file but rather from a buffer which I
provide. The part would look like this

        Content-Disposition: form-data; name="foo";\ filename="/full/path/to/foo"
        Content-Type: application/binary

        <data from a buffer, not from file "foo">

All the examples I can find show only how to do a "real" file upload.
I've tried various permutations without success. In particular the
documentation for CURLFORM_BUFFER ("followed by a string, tells libcurl
that a buffer is to be used to upload data instead of using a file..."
sounds good, e.g.

             res = curl_formadd(&(glb->hg_formpost), &(glb->hg_lastptr),
                     CURLFORM_BUFFER, pnp->pn_path,
                     CURLFORM_BUFFERPTR, strdup(lnkbuf),
                     CURLFORM_CONTENTTYPE, "application/binary",
                     CURLFORM_END);

Can anyone give a sample curl_formadd() invocation for this?

Thanks,
Mohun B

-------------------------------------------------------
This SF.net email is sponsored by Dice.com.
Did you know that Dice has over 25,000 tech jobs available today? From
careers in IT to Engineering to Tech Sales, Dice has tech jobs from the
best hiring companies. http://www.dice.com/index.epl?rel_code=104
Received on 2003-08-20