Hello everyone,
I have a form that allows multiple files to be attached from a file attachment field.
When saving, I export a CSV file with this data, but I would also like to retrieve the names of the files that have been attached.
Is it possible to retrieve the names of the files, for example separated by commas if there are several?
I'm going round in circles on this!
Thank you
Hi Bobby,
Thank you very much, that's great, and it works well for one file, but when there are several files attached, only one name seems to be retrieved.
Thank you, it's already a good basis to work from...
Great!
This would then need modified to be a field with a comma separated name list where it iterates through each file upload, gets the name, and then puts it into a comma separated string in the "target text field".
How important is it that you know the file name against the file being uploaded? Does that matter at all?
Yes, I understand why you would ask that question.
In fact, I need to export the data to a CSV file so that it can then be imported into specific software via FTP, and I would like to retrieve only the file names in my CSV file, as with the other data.
I'm not sure that answers my question, but that's okay. I didn't ask it well.
Try this for multiple file uploads: https://paste2.org/kVBxLzZ0
Again, this is AI generated.
It's work like a charm!
Many thank's Bobby, I'll be able to adapt and integrate it into my csv export.
Have a nice day
Please login or Register to submit your answer
Staff replied 5 months ago
What you say "I export", do you mean that in frm_after_entry_create you create a CSV file and export it to the browser or server? If not how are you doing it? The bottom line is that if you're doing some custom code, using views or hooks, you can achieve your goal.
replied 5 months ago
Thank you, Rob, for your reply.
I am indeed using frm_after_entry_create to create the CSV file using the method I found here: https://www.fdmdigital.co.uk/export-a-form-entry-to-csv-on-submit/
I wanted to complete this by retrieving the labels of the attached files, but when I retrieve the attachment field, I get the URL for accessing the file but not its label!
I imagine there must be a method for retrieving the file names, but I can't find it.
I tried this, but unfortunately without success: https://www.fdmdigital.co.uk/formidable-forms-file-upload-add-ons/
It's surprising that there's no native way to retrieve these labels!
Staff replied 5 months ago
The value that's stored in the Formidable frm_item_metas table for a file is the ID of the entry in wp_posts. So you can always grab that ID, retrieve the wp_posts entry, and retrieve the value of "guid", which contains the full filename. But that leads me to the question of what you mean by "file name", because the URL you're referring to must contain the filename if it's a URL to the file itself.
Staff replied 5 months ago
Based on your question, I've created a hook for this using AI that seems to work on my side. This will need to go into code snippets or a custom plugin or function file.
https://paste2.org/C4txkJAw
Replace the ID's on lines 9, 11, and 13. This will get the form, get the file upload field, capture the base name of that file, and then place that into a target single line text input field.