Commit 824e4dc0 authored by Sergey Lyubka's avatar Sergey Lyubka

Fix file upload iteration

parent d0334977
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
static int send_index_page(struct mg_connection *conn) { static int send_index_page(struct mg_connection *conn) {
const char *data; const char *data;
int data_len, ofs = 0; int data_len, n1, n2;
char var_name[100], file_name[100]; char var_name[100], file_name[100];
mg_printf_data(conn, "%s", mg_printf_data(conn, "%s",
...@@ -19,12 +19,13 @@ static int send_index_page(struct mg_connection *conn) { ...@@ -19,12 +19,13 @@ static int send_index_page(struct mg_connection *conn) {
"<input type=\"submit\" value=\"Upload\" />" "<input type=\"submit\" value=\"Upload\" />"
"</form>"); "</form>");
while ((ofs = mg_parse_multipart(conn->content + ofs, conn->content_len - ofs, n1 = n2 = 0;
var_name, sizeof(var_name), while ((n2 = mg_parse_multipart(conn->content + n1, conn->content_len - n1,
file_name, sizeof(file_name), var_name, sizeof(var_name), file_name,
&data, &data_len)) > 0) { sizeof(file_name), &data, &data_len)) > 0) {
mg_printf_data(conn, "var: %s, file_name: %s, size: %d bytes<br>", mg_printf_data(conn, "var: %s, file_name: %s, size: %d bytes<br>",
var_name, file_name, data_len); var_name, file_name, data_len);
n1 += n2;
} }
mg_printf_data(conn, "%s", "</body></html>"); mg_printf_data(conn, "%s", "</body></html>");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment