]> git.proxmox.com Git - ceph.git/blame - ceph/src/civetweb/docs/api/mg_form_data_handler.md
buildsys: switch source download to quincy
[ceph.git] / ceph / src / civetweb / docs / api / mg_form_data_handler.md
CommitLineData
11fdf7f2
TL
1# Civetweb API Reference
2
3### `struct mg_form_data_handler;`
4
5### Fields
6
7|Field|Description|
8|:---|:---|
9|**`field_found`**|**`int field_found( const char *key, const char *filename, char *path, size_t pathlen, void *user_data )`**;|
10||The callback function `field_found()` is called when a new field has been found. The return value of this callback is used to define how the field should be processed. The parameters contain the following information:|
11||**`key`** - The name of the field as it was named with the `name` tag in the HTML source.|
12||**`filename`** - The name of the file to upload. Please not that this parameter is only valid when the input type was set to `file`. Otherwise this parameter has the value `NULL`.|
13||**`path`** - This is an output parameter used to store the full name of the file including the path to store an incoming file at the computer. This parameter must be provided by the application to Civetweb when a form field of type `file` is found. Please not that together with setting this parameter, the callback function must return `FORM_FIELD_STORAGE_STORE`.i With any other return value the contents of the `path` buffer is ignored by Civetweb.|
14||**`pathlen`** - The length of the buffer where the output path can be stored.|
15||**`user_data`** - A pointer to the value of the field `user_data` of the structure `struct mg_form_data_handler`.|
16||The callback function `field_found()` can return the following values back to Civetweb:|
17||**`FORM_FIELD_STORAGE_SKIP`** - Ignore the field and continue with processing the next field|
18||**`FORM_FIELD_STORAGE_GET`** - Call the callback function `field_get()` to receive the form data|
19||**`FORM_FIELD_STORAGE_STORE`** - Store a file as `path` and overwrite that file if it already exists|
20||**`FORM_FIELD_STORAGE_ABORT`** - Stop parsing the request and ignore all remaining form fields|
21|**`field_get`**|**`int field_get( const char *key, const char *value, size_t valuelen, void *user_data );`**|
22|**`field_store`**|**`int field_store( const char *path, long long file_size, void *user_data );`**|
23||If the callback function `field_found()` returned `FORM_FIELD_STORAGE_STORE`, Civetweb will try to store the received data in a file. If writing the file is successful, the callback function `field_store()` is called. This function is only called after completion of a full upload, not if a file has only partly been uploaded. When only part of a file is received, Civetweb will delete that partly upload in the background and not inform the main application through this callback. The following parameters are provided in the function call:|
24||**`path`** -|
25||**`file_size`** - The path on the server where the file was stored|
26||**`user_data`** - The size of the stored file in bytes|
27|**`user_data`**|**`void *`** The value of the field `user_data` when the callback functions were registered with a call to `mg_handle_form_request();`|
28||The `user_data` field is a user supplied argument that will be passed as parameter to each of callback functions|
29
30### Description
31
32The structure `struct mg_form_data_handler` contains callback functions for handling form fields. Form fields give additional information back from a web page to the server which can be processed by these callback functions.
33
34### See Also
35
36* [`mg_handle_form_request();`](mg_handle_form_request.md)