Handling multiple file uploads in n8n (On Form Submission → Extract from PDF) – Binary field issue

Hey everyone,

I could use some help again :slightly_smiling_face:

I’m trying to upload multiple files at once using the On Form Submission node.
This works in general, but I run into problems in the Extract from PDF node.

Problem

The issue is that the Input Binary Field changes depending on how many files are uploaded.

  • For a single file → no problem (e.g. Datei_Hochladen)

  • For multiple files → n8n seems to increment the field name:

    • Datei_Hochladen

    • Datei_Hochladen_1

    • Datei_Hochladen_2

    • etc.

Because of that, the Extract from PDF node can’t reliably process the input anymore.

Current setup

As you can see in my setup, I’m using:

  • Input Binary Field: Datei_Hochladen

But since the name changes for each uploaded file, it breaks when multiple files are submitted.

What I tried

  • Tested with a Wait node to process files one by one (e.g. every 5 seconds)
    → didn’t really work as expected

  • Tried keeping the same binary field name
    → not possible since it auto-increments

Questions

  • Is there a way to normalize or dynamically handle multiple binary fields in n8n?

  • Do I need to loop over the binary data somehow (e.g. Split in Batches or Function node)?

  • Or is there a better pattern for handling multi-file uploads → PDF extraction?

Would really appreciate any guidance or best practices here :folded_hands:

Thanks in advance for your time and help!

Hi @Leon22 understood!
Just use a code node right after your form submission is completed, to iterate over all those binary keys and one item per time in file, and everything standardized with data key, so what would happen is that when you will place a code like this after your form submission node:

const data = $input.last().json
const binaryData = $input.last().binary

let output = []

Object.keys(binaryData).forEach(b => {
  output.push({
    json: data,
    binary: { data: binaryData[b] }
  })
})

return output

And right after this add your extract from PDF node where input binary field will bedata , so no loop needed, let me know how this goes.

3 Likes

Wow, thank you for The quick response it worked right away. Thank you.

1 Like

Hey

thanks again, your solution worked perfectly right away — really appreciate it!

I’m running into a follow-up issue though:
Now all entries in my database have the same filename in the metadata. It always takes the filename of the first uploaded document and assigns it to all others.

I’m currently passing the filename through the Default Data Loader, but it doesn’t seem to differentiate between the files after splitting them.

I also get a warning in the Default Data Loader related to this.

Is there a way to make sure each item keeps its correct filename from the original binary data?
Or do I need to explicitly map the filename in the Code node when splitting the files?

Also wondering: would this work if I introduce a loop (e.g. Split in Batches) so the files are uploaded one by one — would that ensure the filenames are correctly assigned? Or is that not necessary here?

Would really appreciate any hints — thanks again for your help!

Leon22’s Code node approach works fine for the split, but to preserve individual filenames you need to extract them in the Code node before splitting. try wrapping each file with metadata: { file: binaryData[b], filename: b } where b is the original form field name. Then after Extract PDF, use a Function node to tag each result with its filename before writing to the db. thats what stops all rows from picking up the first file’s name.