Skip to content
Grav 2.1 is out: every page speaks Markdown. Read the announcement →

How to rename a user uploaded file through YAML

admin

Started by Alessandro Ferrari 7 years ago · 2 replies · 1675 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, 6 years ago
13 2071 7 months ago
Forms & Blueprints · by Hugo Oliveira, 8 months ago
0 574 8 months ago
Forms & Blueprints · by Flachy Joe, 9 months ago
9 664 9 months ago
Forms & Blueprints · by Augustus, 9 months ago
7 715 9 months ago
Forms & Blueprints · by Julien, 10 months ago
10 700 10 months ago