<p>You should be using <code>{{currentUser.id}}</code> instead of <code>{currentUser.id}</code></p>

<p>The difference is that double curly brace syntax works on the global scope, while single curly brace syntax tries to resolve itself on the current element. <a href="https://docs.craftcms.com/v2/assets-fields.html#dynamic-subfolder-paths" rel="nofollow noreferrer">Relevant documentation.</a></p>

CC BY-SA 4.0
2018-07-24T06:26:21.370Z
Fantastic! I did not know the rule about single `{`'s current element scope vs `{{`'s global scope. FYI I have used `{{ currentUser.uid }}` which creates a nice complex subdirectory something like: `/images/a4b4f254-1beb-4110-be97-ab1c7d47f2a0/image.jpg` Thank you for your answer.
Adam Menczykowski
CC BY-SA 4.0
2018-11-09T18:48:45.570Z
I want to import assets and save them into their user folders. nothing of the above works... if I use {{currentUser.username}} it'll import the assets to whoever is logged in. {{user.username}} {user.username} does not work {{author.username}} {author.username} does not work as well. isn't there something more specific that will always save it into the users directory. Also if an admin would edit a user it would put it into the wrong directory... I guess I need some help...
outline4
CC BY-SA 4.0
2018-11-10T11:42:35.307Z
After investigating a little more I found out that you can use {id} or {username} if the asset field is attached to a user. it's much safer than using {{ currentUser.id }}.
outline4
CC BY-SA 4.0
2018-07-23T20:11:49.687Z
2018-07-23T20:11:49.687Z
Andris Sevcenko
<p>I need to set an asset field's dynamic subfolder path to the User ID.</p>

<p>The field is within a matrix.</p>

<p>The matrix a field in a User profile.</p>

<p>Setting it to <code>{currentUser.id}</code>, <code>{owner.author.id}</code>, <code>{object.author.id}</code> results in an invalid path message when trying to upload to the asset field.</p>

CC BY-SA 4.0
2018-07-23T16:37:13.413Z
I would like to use `{currentUser.uid}` ideally, so the upload location is anonymous to anyone peeking at the asset URL, however it seems `uid` isn't available on the User model.
Adam Menczykowski
<matrix><user-profile><assets-field>
Asset dynamic subfolder for User Matrix
# Asset dynamic subfolder for User Matrix

(Asked by: username_0 on 2018-07-23)

I need to set an asset field's dynamic subfolder path to the User ID.

The field is within a matrix.

The matrix a field in a User profile.

Setting it to `{currentUser.id}`, `{owner.author.id}`, `{object.author.id}` results in an invalid path message when trying to upload to the asset field.

**Tags:** matrix, user-profile, assets-field
> **Comments:**
> **username_0**: I would like to use `{currentUser.uid}` ideally, so the upload location is anonymous to anyone peeking at the asset URL, however it seems `uid` isn't available on the User model.  

---

## 1 answers

### Answer by username_1 on 2018-07-23. Score: 3 | Accepted answer

You should be using `{{currentUser.id}}` instead of `{currentUser.id}`

The difference is that double curly brace syntax works on the global scope, while single curly brace syntax tries to resolve itself on the current element. [Relevant documentation.](https://docs.craftcms.com/v2/assets-fields.html#dynamic-subfolder-paths)

> **Comments:**
> **username_0**: Fantastic! I did not know the rule about single `{`'s current element scope vs `{{`'s global scope. FYI I have used `{{ currentUser.uid }}` which creates a nice complex subdirectory something like: `/images/a4b4f254-1beb-4110-be97-ab1c7d47f2a0/image.jpg` Thank you for your answer.  
> **username_2**: I want to import assets and save them into their user folders. nothing of the above works... if I use {{currentUser.username}} it'll import the assets to whoever is logged in. {{user.username}} {user.username} does not work {{author.username}} {author.username} does not work as well. isn't there something more specific that will always save it into the users directory. Also if an admin would edit a user it would put it into the wrong directory... I guess I need some help...  
> **username_2**: After investigating a little more I found out that you can use {id} or {username} if the asset field is attached to a user. it's much safer than using {{ currentUser.id }}.  

---

