Buy Now
Sign in

Creating a filename based on a form data field value for an upload.

earthwatch , March 06 at 16:31
Answered
E
earthwatch
Hi,
I have read through the manual and other posts but can not find the answer.
I have a form with 2 field upload options. I would like the file names to have the date and time stamp followed by the first-name and last-name data fields follwoed by the actual name and extension.
If my first name ID is first-name and my last name ID is last-name, how would I write the variable in the 'File name provider' field? I see you can use {var:FN.file.name} and {var:FN.file.extension} but not sure how I combine that to end up with:
{datestamp}{first-name}{last-name}{filename}{file extension}
Thanks a lot
Paul.
admin
Hi Paul,
You should use the field name but not id, you would need something like this:
{date:YmdHis}{data:first_name}{data:last_name}{var:upload_name.file.name}{var:upload_name.file.extension}
Best regards
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
E
earthwatch
Hi Max, so I added the var that you suggested, using the field name in the 'File name provider' field and I got the following:
The 2 files that were uploaded were:
Earthwatch.txt - ended up being '20180307083954PaulSpyker'
logo.jpg - ended up being '20180306155708_logo.jpg'
So the first file was renamed but did not have the extension nor did it keep the original file name.
The second file was not affected and kept the standard naming convention.
My aim is to rename both the files as you have suggested above.
I look forward to your response,
Paul.
admin
Hi Paul,
The "upload_name" in the string should be replaced by the name of the "upload files" action.
How many file upload actions do you have ?
Best regards
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
E
earthwatch
Hi, there are just two files that they can upload, the first is required and the second is not required.
Thanks​
​Paul.
E
earthwatch
Hi Max, that all works, great thank you. Just one last question, if I want to put a hyphen in between the firstname and lastname, is that possible and if so what would the code be in the below:
{date:YmdHis}{data:first_name}{data:last_name}{var:upload2.file.name}{var:upload2.file.extension}
Thanks​
​Paul.
admin
Hi Paul,
Great, so the string would be:
{date:YmdHis}{data:first_name}_{data:last_name}{var:upload2.file.name}{var:upload2.file.extension}
Best regards
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
E
earthwatch
Hi Max, perfect, thanks. I noticed you have to add a . between the last 2 variables else the file extension is part of the filename, but I have added the following and it all works perfectly:
Thanks a lot for your support!
Paul.
{date:YmdHis}_{data:first_name}_{data:last_name}_{var:upload2.file.name}.{var:upload2.file.extension}
admin
Hi Paul,
Good catch!
Best regards
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!