Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

How to rename a user uploaded file through YAML

admin

Started by Alessandro Ferrari 7 years ago · 2 replies · 1941 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 Anna, 2 days ago
2 53 16 hours ago
Forms & Blueprints · by Anna, 3 days ago
7 82 16 hours ago
Forms & Blueprints · by Anna, 1 week ago
5 186 6 days ago
Forms & Blueprints · by TomW, 1 month ago
3 379 1 month ago
Forms & Blueprints · by Japhy, 2 months ago
2 595 2 months ago