How to save form data and uploaded files into the same unique subdirectory?

The forms plugin allows us to use the save action, which will place the form data in a file with a timestamp of our own choice within the user/data directory. That’s fantastic. The file input field allows us to chose a destination, which boils down to either using @self, meaning that the files will be saved where the page’s template.md file is located, or to hand in a path to a directory. This is nice.

However, what I’m trying to achieve is this:

  • Save the form AND its associated uploaded files in the same directory
  • There should be one directory for each submitted form and it should therefore have a unique name (like the file saved by save does)

In other words, I would need to be able to:

  1. Somehow tell the save action to create a subdirectory with a certain format, just like we can define the timestamp/ID format for the file right now
  2. Use that same directory name (format string) in the destination property for the file field

Is this possible? Is there any other way to achieve the desired result? Or will I have to create/modify a plugin?

EDIT: Alternatively, is there any other way to associate an uploaded form with the files uploaded through it, so other scripts can later make that connection and show the form data and the uploaded files for a given submission?

Hi Julien,

Did you manage to resolve the issue of form text & attachments into a unique folder?

I am facing the same issue.

Many thanks,

Peter.

Unfortunately, not yet. I’ve created an issue on Github in late 2018, with the latest reply from the Grav team in early 2019 stating that they might have an idea on how to implement this. However, ever since there hasn’t been any updates.

Let me know if you manage to get this to work, I’m also still interested in a solution.

In what aspect is the Add Page By Form Plugin failing to achieve this? Assuming you tried it?

Did not think to try that one thanks bleutzinn.

Will explore.

Peter.