Skip to content

Handle multiple file uploads #182

@sc68cal

Description

@sc68cal

It is possible to have a file input that has multiple files uploaded.

https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/multiple

<form action="/{{ jetzig_view }}" method="POST" enctype="multipart/form-data" id="myform">
        <input class="form-control" type="file" name="attachments" multiple>
</form>

HTTP POST parameters

------geckoformboundarye011264df08dce9643f770aab11f4ec7
Content-Disposition: form-data; name="attachments"; filename="file_upload_1.txt"
Content-Type: text/plain

foo

------geckoformboundarye011264df08dce9643f770aab11f4ec7
Content-Disposition: form-data; name="attachments"; filename="file_upload_2.txt"
Content-Type: text/plain

bar

------geckoformboundarye011264df08dce9643f770aab11f4ec7--

Currently calling request.file only appears to return the first attachment, and looking briefly through the code there does not appear to be any handling of multiple, although I could be mistaken.

    if (try request.file("attachments")) |attachments| {
        try request.server.logger.DEBUG("{s}", .{attachments.content});
    }
DEBUG [2025-03-25T16:14:34] foo

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions