1
0
mirror of https://github.com/lammertb/libhttp.git synced 2025-07-31 08:24:23 +03:00

Fix multiple file upload (issue #55)

This commit is contained in:
bel
2015-01-05 15:05:01 +01:00
parent ea4b4c2e32
commit a5eadbca86
2 changed files with 11 additions and 2 deletions

View File

@ -36,6 +36,7 @@ static int begin_request_handler(struct mg_connection *conn)
"<form method=\"POST\" action=\"/handle_post_request\" "
" enctype=\"multipart/form-data\">"
"<input type=\"file\" name=\"file\" /> <br/>"
"<input type=\"file\" name=\"file2\" /> <br/>"
"<input type=\"submit\" value=\"Upload\" />"
"</form>"
""

View File

@ -5877,9 +5877,17 @@ int mg_upload2(struct mg_connection *conn, const char *destination_dir, int time
break;
}
/* Get headers for this part of the multipart message */
/* terminate header */
buf[headers_len-1]=0;
s = &buf[bl];
/* Scan for the boundary string and skip it */
if (buf[0]=='-' && buf[1]=='-' && !memcmp(buf+2, boundary, boundary_len)) {
s = &buf[bl];
} else {
s = &buf[2];
}
/* Get headers for this part of the multipart message */
memset(&part_request_info, 0, sizeof(part_request_info));
parse_http_headers(&s, &part_request_info);
assert(&buf[headers_len-1] == s);