2000-06-06 22:54:42 +08:00
|
|
|
.\" You can view this file with:
|
|
|
|
.\" nroff -man [file]
|
2001-05-31 16:41:42 +08:00
|
|
|
.\" $Id$
|
2000-06-06 22:54:42 +08:00
|
|
|
.\"
|
2001-05-23 02:16:24 +08:00
|
|
|
.TH curl_formparse 3 "21 May 2001" "libcurl 7.7.4" "libcurl Manual"
|
2000-06-06 22:54:42 +08:00
|
|
|
.SH NAME
|
2001-08-21 21:18:07 +08:00
|
|
|
curl_formparse - add a section to a multipart/formdata HTTP POST:
|
|
|
|
deprecated (use curl_formadd instead)
|
2000-06-06 22:54:42 +08:00
|
|
|
.SH SYNOPSIS
|
|
|
|
.B #include <curl/curl.h>
|
|
|
|
.sp
|
2001-04-23 19:55:25 +08:00
|
|
|
.BI "CURLcode curl_formparse(char * " string, " struct HttpPost ** " firstitem,
|
|
|
|
.BI "struct HttpPost ** " lastitem ");"
|
2000-06-06 22:54:42 +08:00
|
|
|
.ad
|
|
|
|
.SH DESCRIPTION
|
|
|
|
curl_formparse() is used to append sections when building a multipart/formdata
|
2001-04-23 19:55:25 +08:00
|
|
|
HTTP POST (sometimes refered to as rfc1867-style posts). Append one section at
|
|
|
|
a time until you've added all the sections you want included and then you pass
|
2001-05-23 02:16:24 +08:00
|
|
|
the \fIfirstitem\fP pointer as parameter to \fBCURLOPT_HTTPPOST\fP.
|
2001-04-23 19:55:25 +08:00
|
|
|
\fIlastitem\fP is set after each call and on repeated invokes it should be
|
|
|
|
left as set to allow repeated invokes to find the end of the list in a faster
|
2001-04-23 20:36:02 +08:00
|
|
|
way. \fIstring\fP must be a zero terminated string abiding to the syntax
|
|
|
|
described in a section below
|
2001-04-23 19:55:25 +08:00
|
|
|
|
2001-05-23 02:16:24 +08:00
|
|
|
The pointers \fI*firstitem\fP and \fI*lastitem\fP should both be pointing to
|
|
|
|
NULL in the first call to this function. All list-data will be allocated by
|
|
|
|
the function itself. You must call \fIcurl_formfree\fP after the form post has
|
|
|
|
been done to free the resources again.
|
|
|
|
|
|
|
|
This function will copy all input data and keep its own version of it
|
|
|
|
allocated until you call \fIcurl_formfree\fP. When you've passed the pointer
|
|
|
|
to \fIcurl_easy_setopt\fP, you must not free the list until after you've
|
|
|
|
called \fIcurl_easy_cleanup\fP for the curl handle.
|
2001-04-23 19:55:25 +08:00
|
|
|
|
|
|
|
See example below.
|
2000-06-06 22:54:42 +08:00
|
|
|
.SH "FORM PARSE STRINGS"
|
|
|
|
The
|
|
|
|
.I string
|
|
|
|
parameter must be using one of the following patterns. Note that the []
|
|
|
|
letters should not be included in the real-life string.
|
|
|
|
.TP 0.8i
|
|
|
|
.B [name]=[contents]
|
|
|
|
Add a form field named 'name' with the contents 'contents'. This is the
|
|
|
|
typcial contents of the HTML tag <input type=text>.
|
|
|
|
.TP
|
|
|
|
.B [name]=@[filename]
|
|
|
|
Add a form field named 'name' with the contents as read from the local file
|
|
|
|
named 'filename'. This is the typcial contents of the HTML tag <input
|
|
|
|
type=file>.
|
|
|
|
.TP
|
|
|
|
.B [name]=@[filename1,filename2,...]
|
|
|
|
Add a form field named 'name' with the contents as read from the local files
|
|
|
|
named 'filename1' and 'filename2'. This is identical to the upper, except that
|
|
|
|
you get the contents of several files in one section.
|
|
|
|
.TP
|
2001-02-23 06:33:49 +08:00
|
|
|
.B [name]=@[filename];[type=<content-type>]
|
2000-06-06 22:54:42 +08:00
|
|
|
Whenever you specify a file to read from, you can optionally specify the
|
|
|
|
content-type as well. The content-type is passed to the server together with
|
|
|
|
the contents of the file. curl_formparse() will guess content-type for a
|
|
|
|
number of well-known extensions and otherwise it will set it to binary. You
|
|
|
|
can override the internal decision by using this option.
|
|
|
|
.TP
|
2001-02-23 06:33:49 +08:00
|
|
|
.B [name]=@[filename1,filename2,...];[type=<content-type>]
|
2000-06-06 22:54:42 +08:00
|
|
|
When you specify several files to read the contents from, you can set the
|
|
|
|
content-type for all of them in the same way as with a single file.
|
|
|
|
.PP
|
|
|
|
.SH RETURN VALUE
|
|
|
|
Returns non-zero if an error occurs.
|
2001-04-23 19:55:25 +08:00
|
|
|
.SH EXAMPLE
|
|
|
|
|
|
|
|
HttpPost* post = NULL;
|
|
|
|
HttpPost* last = NULL;
|
|
|
|
|
|
|
|
/* Add an image section */
|
|
|
|
curl_formparse("picture=@my-face.jpg", &post, &last);
|
|
|
|
/* Add a normal text section */
|
|
|
|
curl_formparse("name=FooBar", &post, &last);
|
|
|
|
/* Set the form info */
|
2001-05-03 22:24:37 +08:00
|
|
|
curl_easy_setopt(curl, CURLOPT_HTTPPOST, post);
|
2001-04-23 19:55:25 +08:00
|
|
|
|
2000-06-06 22:54:42 +08:00
|
|
|
.SH "SEE ALSO"
|
2001-05-23 02:16:24 +08:00
|
|
|
.BR curl_easy_setopt "(3), "
|
2001-08-21 21:18:07 +08:00
|
|
|
.BR curl_formadd "(3), "
|
2001-05-23 02:16:24 +08:00
|
|
|
.BR curl_formfree "(3)
|
2000-06-06 22:54:42 +08:00
|
|
|
.SH BUGS
|
|
|
|
Surely there are some, you tell me!
|
|
|
|
|