mirror of
https://github.com/lammertb/libhttp.git
synced 2025-08-06 05:02:40 +03:00
Fix multiple file upload (issue #55)
This commit is contained in:
@@ -36,6 +36,7 @@ static int begin_request_handler(struct mg_connection *conn)
|
|||||||
"<form method=\"POST\" action=\"/handle_post_request\" "
|
"<form method=\"POST\" action=\"/handle_post_request\" "
|
||||||
" enctype=\"multipart/form-data\">"
|
" enctype=\"multipart/form-data\">"
|
||||||
"<input type=\"file\" name=\"file\" /> <br/>"
|
"<input type=\"file\" name=\"file\" /> <br/>"
|
||||||
|
"<input type=\"file\" name=\"file2\" /> <br/>"
|
||||||
"<input type=\"submit\" value=\"Upload\" />"
|
"<input type=\"submit\" value=\"Upload\" />"
|
||||||
"</form>"
|
"</form>"
|
||||||
""
|
""
|
||||||
|
@@ -5877,9 +5877,17 @@ int mg_upload2(struct mg_connection *conn, const char *destination_dir, int time
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get headers for this part of the multipart message */
|
/* terminate header */
|
||||||
buf[headers_len-1]=0;
|
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));
|
memset(&part_request_info, 0, sizeof(part_request_info));
|
||||||
parse_http_headers(&s, &part_request_info);
|
parse_http_headers(&s, &part_request_info);
|
||||||
assert(&buf[headers_len-1] == s);
|
assert(&buf[headers_len-1] == s);
|
||||||
|
Reference in New Issue
Block a user