FTP multiple files from n8n form

I have managed to upload a file from a HTTP request using the parameter data.

I now need to use a n8n form to request some data and files.

This is workflow works.

I see the following result

[
  {
    "FullName": "Steve Warby",
    "Tel No": "345345345",
    "How many risk assessments do you use per month": 3,
    "Risk Assesment Files": [
      {
        "filename": "1455aa6ab8c14311a2816e2996eac4c8.pdf",
        "mimetype": "application/pdf",
        "size": 29351
      },
      {
        "filename": "db556f4f2e8f4d5f9ed7cdb197c97a79.pdf",
        "mimetype": "application/pdf",
        "size": 26293
      },
      {
        "filename": "f8b647bed31f43a8a6971589514c2063.pdf",
        "mimetype": "application/pdf",
        "size": 25918
      },
      {
        "filename": "bc860aacbf524988bd99b6e88a7e5643.pdf",
        "mimetype": "application/pdf",
        "size": 26991
      }
    ],
    "submittedAt": "2024-09-30T09:48:12.925-04:00",
    "formMode": "test"
  }
]

How do I FTP all the files that are uploaded by the form ?

  • n8n version: 1.59
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Render):
  • Operating system: Windows

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

One step closer.

This workflow loops and runs the FTP once for each file

I cannot work out how to get the filename in each loop.

If I drag the filename ie {{ $(‘Code’).item.json[“Risk Assesment Files”][0].filename }} This overwrites with the same filename.

So how do I get each filename in from the loop.

json in the loop

[
  {
    "FullName": "",
    "Tel No": "",
    "How many risk assessments do you use per month": 0,
    "Risk Assesment Files": [
      {
        "filename": "f8b647bed31f43a8a6971589514c2063.pdf",
        "mimetype": "application/pdf",
        "size": 25918
      },
      {
        "filename": "bc860aacbf524988bd99b6e88a7e5643.pdf",
        "mimetype": "application/pdf",
        "size": 26991
      },
      {
        "filename": "0f405f71658148eeb56ded2745107781 (1).pdf",
        "mimetype": "application/pdf",
        "size": 27092
      },
      {
        "filename": "0f405f71658148eeb56ded2745107781.pdf",
        "mimetype": "application/pdf",
        "size": 27092
      },
      {
        "filename": "8aa93fafc6f04918b841693bdc39c2ea.pdf",
        "mimetype": "application/pdf",
        "size": 26508
      }
    ],
    "submittedAt": "2024-09-30T11:12:59.814-04:00",
    "formMode": "test"
  }
]

Finally found it

{{ $json[“Risk Assesment Files”][$runIndex].filename }}

$runIndex give the number of each run.

One final issue ( hopefully)

I use the following syntax to FTP the files

/public_html/risk/interest/{{ $(‘MySQL’).item.json.insertId }}/{{ $(‘Code’).item.json[“Risk Assesment Files”][$runIndex].filename }}

This creates a folder if not exist and uploads the file.

On Render.com and using writeFile the error is folder does not exist.

Is there a way to create a folder ???

Hey @Steve_Warburton , you do not need the Loop node for that. You can unload multiple files as demonstrated below. You can add dynamic folders if needed. You also do not need the json part to have the files uploaded.

Thanks for the help. I used a loop in the end ( it’s more visual )