cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: CURLFORM_BUFFER vs CURLFORM_PTR

From: Armel Asselin <asselin.armel_at_wanadoo.fr>
Date: Thu, 31 Aug 2006 08:56:11 +0200

>> The doc for CURLFORM_BUFFER says "The given string is used as the value
>> of the file name field ..." while CURLFORM_PTRNAME says "... followed by
>> a string is used for the name of this part." Thus each of these provides
>> a name, and each comes with a way to specify the start of the buffer and
>> its length.
>
> CURLFORM_PTRNAME sets the name for the part, CURLFORM_BUFFER sets the
> *file name* used in the part and then the BUFFERPTR and BUFFERLENGTH sets
> the content of that part and makes it a "file upload part".
just to restate another way: you can think of setopt(CURLFORM_BUFFER,
filename) as:
ptr = curl_malloc(filesize(filename))
load(filename, ptr)
setopt(CURLFORM_BUFFERPTR, ptr)
setopt(CURLFORM_BUFFERLENGTH, filesize(filename))
...
curl_free(ptr);

Mohun: is it more clear?

HIH
Armel
Received on 2006-08-31