# Create Folders on file upload

**URL:** <https://discourse.cakephp.org/t/create-folders-on-file-upload/12290>\
**Category:** Need Help\
**Created:** [October 29, 2024, 11:05am UTC](https://discourse.cakephp.org/t/create-folders-on-file-upload/12290 "2024-10-29T11:05:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Howan](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/howan/32/3182_2.png) [@Howan](https://discourse.cakephp.org/u/Howan)\
**Post date:** [October 29, 2024, 11:05am UTC](https://discourse.cakephp.org/t/create-folders-on-file-upload/12290/1 "2024-10-29T11:05:08Z")

</div>

Hi everyone,

i have a little problem with my file upload.  
I have Tickets with multiple TicketSnaps. Each TicketSnap can also have a uploaded picture or pdf.  
I want that all pictures go into one folder named as the Ticket.

I thought this line would do it.

```auto
'path' => 'webroot/uploads/{field:ticket_id}', // Create a folder for each ticket

```

but as you can see in the pictures my folders are now named

> {field:ticket\_id}

Here the full function

```auto
 public function initialize(array $config): void
    {
        parent::initialize($config);

        $this->setTable('ticket_snaps');
        $this->setDisplayField('id');
        $this->setPrimaryKey('id');

        $this->addBehavior('Timestamp');

        $this->belongsTo('Tickets', [
            'foreignKey' => 'ticket_id',
            'joinType' => 'INNER',
        ]);
        $this->belongsTo('Users', [
            'foreignKey' => 'user_id',
            'joinType' => 'INNER',
        ]);

        $this->addBehavior('Josegonzalez/Upload.Upload', [
            'photo' => [
                'path' => 'webroot/uploads/{field:ticket_id}', // Create a folder for each ticket
            ],
        ]);

    }

```

 ![Bildschirmfoto 2024-10-29 um 11.53.44](https://canada1.discourse-cdn.com/flex029/uploads/cakephp/original/2X/2/2c1c3ea19bd6a2911d5e00fc47b0a7c701afb40d.jpeg)

The ticket\_id should be present and is stored correct in the DB.

 ![Bildschirmfoto 2024-10-29 um 11.57.43](https://canada1.discourse-cdn.com/flex029/uploads/cakephp/original/2X/2/2fff23078da535a3f264fa60f3b6ebe1b0bc40fe.png)

Thank you 🙏

---

<div class="post-metadata">

**Author:** ![Howan](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/howan/32/3182_2.png) [@Howan](https://discourse.cakephp.org/u/Howan)\
**Post date:** [October 29, 2024, 11:47am UTC](https://discourse.cakephp.org/t/create-folders-on-file-upload/12290/2 "2024-10-29T11:47:12Z")

</div>

Hey Leute,

Das Problem ist gelöst.  
GPT-40 wusste es nicht aber die 01-Preview konnte mir helfen. 🥳

> Das Problem liegt darin, dass der Platzhalter {field:ticket\_id} nicht korrekt interpretiert wird. Im **josegonzalez/cakephp-upload** Plugin sollte der Platzhalter für ein Feld folgendermaßen geschrieben werden: {field-value:ticket\_id}.
