Field Name prefix for Uploaded file

dr drgolden 24 Mar, 2019
As part of a conference speakers registration form individuals are asked to upload multiple files (bio,photo, presentation, etc.) Because there are multiple speakers (around 40+) , and the potential of 3 or more uploaded files for each speaker, there re a lot of uploaded files to manage.
​
To make organization easier, I have prefixed the uploaded file with the presenters name with this code:
​
<?php
return $form->data['presenter_name'].'-'.date('Ymd').'_'.$file_name;
?>
​
So the source (presenter) of the uploaded file is in the file name. So I have a file name which looks like: John Smith-20190324_JohnSmith.pdf
​
I would like to also add the FieldName ( bio,photo, presentation, etc.) , so that the file name looks like: John Smith-bio--20190324_JohnSmith.pdf
​
Any ideas?
dr drgolden 24 Mar, 2019
I forgot to mention, this is Chronoforms v5
Gr GreyHead 25 Mar, 2019
Hi drgolden,
​
Can you not add that into the code you have?
<?php
return $form->data['presenter_name'].'-bio-'.date('Ymd').'_'.$file_name;
?>
Bob
dr drgolden 25 Mar, 2019
There are 3 upload fields,.. 1) bio, 2) photo, and 3) presentation. I would like to use the name of each field to identify which "category" the file belongs to. Is it a bio, photo, or presentation? I can't always tell from the file extension.
Gr GreyHead 25 Mar, 2019
Hi drgolden,
​
The simplest way may be to use a separate Files Upload action for each of your File Fields - that way you can use the code I suggested.
​
Otherwise you need to have some way to identify the file type and then use PHP to rename it after the Files Upload action.
​
Bob
This topic is locked and no more replies can be posted.