Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Forms & Blueprints

How to rename a user uploaded file through YAML

admin

Started by Alessandro Ferrari 7 years ago · 2 replies · 1454 views
7 years ago

So basically i added a form in a theme settings page so the user can upload his own logo, however i want the uploaded file to be called as 'logo'.png. Is there an option to rename the file?

7 years ago

@dev_on_a_journey, Would you mind sharing why you would like the uploaded file to have predefined name?

When using the file field in the 'blueprints.yaml' of your theme, it will save the uploaded file into the desired destination folder and write the file's properties into '/user/config/themes/your-theme.yaml'. Then, in Twig, you can retrieve the uploaded file's properties (e.g. name, path) by referencing the theme's config.

See How to: Add a file upload for more explaination and samples.

7 years ago

@pamtbaau Yeah you are right, I'm a beginner I didn't know that. I solved by using a Twig code took from a theme. Later today I'll upload the code! Thank you!

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1135 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 60 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 132 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 108 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 127 7 months ago