Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 10, 2026

Prologue was only capturing the last file when multiple files were uploaded using <input type="file" name="files" multiple />. The FormPart data structure overwrote entries with duplicate names.

Changes

Core data structure (types.nim)

  • Changed FormPart.data from OrderedTableRef[string, tuple[...]] to OrderedTableRef[string, seq[tuple[...]]]
  • Updated [] operator to return first item for backward compatibility
  • Updated []= operator to append instead of replace

Form parser (form.nim)

  • Modified parseFormPart to accumulate files with same name into sequences
  • Fixed header parsing to reference last-added item with [^1]

API (context.nim)

  • Added getUploadFiles(name: string): seq[UploadFile] for retrieving all files
  • Existing getUploadFile(name: string) returns first file, unchanged behavior

Usage

proc handleUpload(ctx: Context) {.async.} =
  # New: get all files
  let files = ctx.getUploadFiles("files")
  for file in files:
    file.save("uploads/")
  
  # Old API still works, returns first file
  let file = ctx.getUploadFile("files")

Example in examples/multifile_upload/ demonstrates complete implementation.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https /usr/lib/apt/methods/https (dns block)
  • nim-lang.org
    • Triggering command: /usr/bin/curl curl REDACTED -sSf (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>handle multiple file upload from a single input element</issue_title>
<issue_description>Hello friends, does prologue support retrieving multiple file comming from the same input element?

given the following html form:

<form method="post" action="/uploadFile" enctype="multipart/form-data" >
    <input type="file" name="files" multiple />
    <input type="submit" value="Upload" />
</form>

how do I get the multiple file user uploaded from Context object?

currently ctx.getUploadFile("files") can only get one of the file. Am I missing some other api?

Thanks in advance</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix multiple file upload handling from single input Add support for multiple file uploads from a single input element Jan 10, 2026
Copilot AI requested a review from ringabout January 10, 2026 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

handle multiple file upload from a single input element

2 participants