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

**URL:** <https://forum.getkirby.com/t/how-to-upload-files-via-textarea-or-files-field-to-a-subfolder-subdirectory/16189>\
**Category:** Questions\
**Tags:** v3\
**Created:** [November 5, 2019, 10:40pm UTC](https://forum.getkirby.com/t/how-to-upload-files-via-textarea-or-files-field-to-a-subfolder-subdirectory/16189 "2019-11-05T22:40:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![warg](https://avatars.discourse-cdn.com/v4/letter/w/90ced4/32.png) [@warg](https://forum.getkirby.com/u/warg)\
**Post date:** [November 5, 2019, 10:40pm UTC](https://forum.getkirby.com/t/how-to-upload-files-via-textarea-or-files-field-to-a-subfolder-subdirectory/16189/1 "2019-11-05T22:40:03Z")

</div>

Hello,

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](https://getkirby.com/docs/reference/panel/fields/textarea#file-upload-and-select) 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,

---

<div class="post-metadata">

**Author:** ![warg](https://avatars.discourse-cdn.com/v4/letter/w/90ced4/32.png) [@warg](https://forum.getkirby.com/u/warg)\
**Post date:** [November 5, 2019, 11:21pm UTC](https://forum.getkirby.com/t/how-to-upload-files-via-textarea-or-files-field-to-a-subfolder-subdirectory/16189/2 "2019-11-05T23:21:09Z")

</div>

Closest I got so far is this field:

```auto
          files:
            type: files
            uploads:
              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 `uploaded_files.de.txt` which references this `uploaded_files.yml` blueprint:

```auto
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.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [November 5, 2019, 11:26pm UTC](https://forum.getkirby.com/t/how-to-upload-files-via-textarea-or-files-field-to-a-subfolder-subdirectory/16189/3 "2019-11-05T23:26:15Z")

</div>

What is the purpose of the `uploaded_files.de.txt` file`

```auto
textarea:
  uploads:
    # 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.

---

<div class="post-metadata">

**Author:** ![warg](https://avatars.discourse-cdn.com/v4/letter/w/90ced4/32.png) [@warg](https://forum.getkirby.com/u/warg)\
**Post date:** [November 5, 2019, 11:30pm UTC](https://forum.getkirby.com/t/how-to-upload-files-via-textarea-or-files-field-to-a-subfolder-subdirectory/16189/4 "2019-11-05T23:30:33Z")

</div>

> [@texnixe](#):
>
> parent: page.children.find(‘test’)

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?

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [November 5, 2019, 11:32pm UTC](https://forum.getkirby.com/t/how-to-upload-files-via-textarea-or-files-field-to-a-subfolder-subdirectory/16189/5 "2019-11-05T23:32:14Z")

</div>

> [@warg](#):
>
> `page.children.test`

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

---

<div class="post-metadata">

**Author:** ![warg](https://avatars.discourse-cdn.com/v4/letter/w/90ced4/32.png) [@warg](https://forum.getkirby.com/u/warg)\
**Post date:** [November 5, 2019, 11:37pm UTC](https://forum.getkirby.com/t/how-to-upload-files-via-textarea-or-files-field-to-a-subfolder-subdirectory/16189/6 "2019-11-05T23:37:10Z")

</div>

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

I changed my files field to this now:

```auto
          files:
            type: files
            uploads:
              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.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [November 5, 2019, 11:41pm UTC](https://forum.getkirby.com/t/how-to-upload-files-via-textarea-or-files-field-to-a-subfolder-subdirectory/16189/7 "2019-11-05T23:41:34Z")

</div>

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

> **[Subpage builder](https://getkirby.com/docs/cookbook/extensions/subpage-builder)**
>
> Auto-generate subpages when you create a new page

Good night 🛌.

---

<div class="post-metadata">

**Author:** ![warg](https://avatars.discourse-cdn.com/v4/letter/w/90ced4/32.png) [@warg](https://forum.getkirby.com/u/warg)\
**Post date:** [November 5, 2019, 11:42pm UTC](https://forum.getkirby.com/t/how-to-upload-files-via-textarea-or-files-field-to-a-subfolder-subdirectory/16189/8 "2019-11-05T23:42:46Z")

</div>

. . . 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!
