diff --git a/examples/embedded_c/embedded_c.c b/examples/embedded_c/embedded_c.c index 23857fc2..6cb30826 100644 --- a/examples/embedded_c/embedded_c.c +++ b/examples/embedded_c/embedded_c.c @@ -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; diff --git a/src/handle_form.inl b/src/handle_form.inl index 514ef112..a620f2d5 100644 --- a/src/handle_form.inl +++ b/src/handle_form.inl @@ -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;