mirror of
https://github.com/lammertb/libhttp.git
synced 2025-08-07 16:02:55 +03:00
Alternative to mg_upload (Step 39/?)
This commit is contained in:
@@ -225,13 +225,24 @@ field_get(const char *key,
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
field_stored(const char *path, void *user_data)
|
||||
{
|
||||
struct mg_connection *conn = (struct mg_connection *)user_data;
|
||||
|
||||
mg_printf(conn, "stored as %s\r\n\r\n", path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
FormHandler(struct mg_connection *conn, void *cbdata)
|
||||
{
|
||||
/* Handler may access the request info using mg_get_request_info */
|
||||
const struct mg_request_info *req_info = mg_get_request_info(conn);
|
||||
int ret;
|
||||
struct mg_form_data_handler fdh = {field_found, field_get, 0};
|
||||
struct mg_form_data_handler fdh = {field_found, field_get, field_stored, 0};
|
||||
|
||||
/* TODO: Checks before calling handle_form_data ? */
|
||||
(void)req_info;
|
||||
|
@@ -588,7 +588,7 @@ mg_handle_form_data(struct mg_connection *conn,
|
||||
|
||||
if (disposition == FORM_DISPOSITION_STORE) {
|
||||
/* Store the content to a file */
|
||||
FILE *fstore = fopen(path, "wb");
|
||||
fstore = fopen(path, "wb");
|
||||
if (fstore != NULL) {
|
||||
size_t towrite, n;
|
||||
|
||||
|
Reference in New Issue
Block a user