diff options
| -rw-r--r-- | main.c | 19 | ||||
| m--------- | slweb | 0 |
2 files changed, 16 insertions, 3 deletions
@@ -1139,12 +1139,25 @@ end: return ret; } +static const char *get_upload_dir(const struct http_post *const po) +{ + for (size_t i = 0; i < po->npairs; i++) + { + const struct http_post_pair *p = &po->pairs[i]; + + if (!strcmp(p->name, "dir")) + return p->value; + } + + return NULL; +} + static int upload_files(const struct http_payload *const p, struct http_response *const r, const struct auth *const a) { const struct http_post *const po = &p->u.post; const char *const root = auth_dir(a), *const user = p->cookie.field, - *const dir = po->dir; + *const dir = get_upload_dir(po); if (!po->files) { @@ -1181,9 +1194,9 @@ static int upload_files(const struct http_payload *const p, return page_bad_request(r); } - for (size_t i = 0; i < po->n; i++) + for (size_t i = 0; i < po->nfiles; i++) { - if (upload_file(&po->files[i], user, root, po->dir)) + if (upload_file(&po->files[i], user, root, dir)) { fprintf(stderr, "%s: upload_file failed\n", __func__); return -1; diff --git a/slweb b/slweb -Subproject 6c7faa7f9063aca15345c9aeb95d651a5fe983f +Subproject 34d716082a0136056373f3d0c6ed7abce45484b |
