How to upload files via textarea or files field to a subfolder/subdirectory?


I would like to have any via textarea or files field uploaded file of a page being uploaded to a specific subfolder/subdirectory of the current page specified in the blueprint. Is this possible?

I found this information but I don’t see a context between files property and uploads property of the textfield and what I would like to achieve:

By default all files will be uploaded to the current page and without a predefined template. With the additional options you can fetch files from anywhere and upload them to specific pages. You can also control which file template should be assigned by default:

I fiddled around with these two options but except a non-existing template applied to my uploads, I see no difference. How can I achieve a subfolder for my uploads on a single page?

Best Regards,

Closest I got so far is this field:

            type: files
              parent: page.children.test
              template: uploaded-files

This files field is used to upload files which should be stored in the subfolder (page) test. I created the test folder manually and created a file called which references this uploaded_files.yml blueprint:

title: Uploaded Files
preset: files

On an upload via this files field, I get this error:

Call to a member function createFile() on null

No clue if I’m on the right way or completely wrong. Right now, I’m not sure what specifies the file location/destination.

What is the purpose of the file`

    # find the upload folder, page must exist, otherwise it probably falls back to current page or throws an error
    parent: page.children.find('test')
    # assign the template
    template: textarea-upload

The template doesn’t have to exist for this to work, I think.

However, you would have to use a hook that automatically creates the subpage on page creation for this setup to work.

Hi @texnixe! First of all, thank you for your 24/7 epic support here!

Can you explain to me why the find part matters here? I tried it before with

parent: page.children.test

because I suspected that I can provide the ID without a find because I’m aware that it exists and should exist always (given I keep care of it via some hook, like you mentioned). Is there a meaningful context behind the notation of the query language I did provide or would this be always an invalid query?

test is not a method, this syntax doesn’t exist.

1 Like

The hassle of dealing with different (query) languages on a daily basis :frowning:

I changed my files field to this now:

            type: files
              parent: page.children.find('test')

The test folder is created and the file is properly uploaded. Deleting works after clicking on the file and using the delete option there.

If you ever need to create a set of subpages on page creation, the subpage builder might be useful:

Good night :sleeping_bed:.

1 Like

. . . so much to learn left but my page is getting closer and closer to its ready to be published status!

Good night, I appreciate your great support!