How to rename the file to username and the current date?

rename uploaded files to include username and date.

Overview

The user needed to automatically rename uploaded files with the submitter's username and the current date within CF.
Use the File Name provider box in the Upload files action with a specific naming string that includes the username and date shortcodes.

Answered
ChronoForms v6
Ca Carlos angel 16 Apr, 2018
Hi.
I need help.
When a user submits a file, I need this file to be renamed to the name of the user it is sending and the current upload date.

Thank you to anyone who can help me.πŸ™‚
Gr GreyHead 21 Apr, 2018
Hi Carlos angel,
​
You can use the File Name provider box in the Upload files action to set a custom name. I think that you can use any of the CFv6 shortcodes in there.
​
Bob
Ca Carlos angel 21 May, 2018
Hi, Gray.
I've already tried using the option that chromoforms to rename the files while uploading them, but I could not.
I do not know how to use php to be able to do a function that does rename the file. But if you can help me in this, I thank you very much.
Gr GreyHead 22 May, 2018
Answer
Hi Carlos angel,
​
Please try using a string like this in the File Name Provider box of the Upload Files action
{var:upload6.file.name}_{user:username}_{date:Y-m-d_H:i}.{var:upload6.file.extension} 
Replace upload 6 with the name of your Upload Files action. Note that you may need to make sure that there are no spaces in the name depending on what you want to do with it.
​
Bob
Ca Carlos angel 22 May, 2018
Hi, Grey.

Thanks for helping me. You helped me do what I needed. Sorry for the inconvenience, but I'm still learning to mess with chronoforms.

Just one more thing. Is there a way to create a directory as soon as the user uploads a file for the first time?
This topic is locked and no more replies can be posted.