What is the correct way to rename an uploaded file using tokens? I am building a webform. I have a Name field that uses first and last name.
I have an image upload field where I want to rename the image to lastname-firstname.jpg.
In the properties for the file upload, I selected Rename files for the pattern [webform:element:name:last__title]-[webform:element:name:first__title].
When I test this using John Smith, the file is getting renamed, but it is being renamed to last-name-first-name.png instead of smith-john.jpg.
I'm guessing I'm doing something wrong with the pattern, but I don't know what.
This is the field definition.
name:
  '#type': name
  '#title': Name
  '#title__access': false
  '#first__title': 'First Name'
  '#middle__access': false
  '#last__title': 'Last Name'
  '#suffix__access': false
  '#degree__access': false
I had the same issue. The answer was buried way down in Browse available tokens.
I wanted to rename an uploaded file based on the responses to the last_name and first_name fields. The pattern that worked was [webform_submission:values:last_name]_[webform_submission:values:first_name].