2

when setting a Default Upload Location for a field that’s attached to a User, what’s the variable to use that would ensure the file is uploaded to the User I’m editing’s account in the back end, and not my admin user account - which is what {{currentUser.username}} does?

I haven't been able to find out and everything I've tried hasn't worked. e.g., Could not resolve the subpath “{user.username}”. And {{ user.username }} uploads to a folder for my admin account.

2
  • Have you tried just {user} or if you're in a Matrix block, {owner.user}?
    – Brad Bell
    Mar 24 '17 at 18:33
  • Yep; "Could not resolve the subpath “{user}”." is what I get :/ Mar 27 '17 at 8:36
2

Assuming you want the folders to be named after the users' IDs (since they won't change), the subpath should be {id}.

1
  • Bizarrely, {id} allowed me to save the User with the uploaded Asset, but browsing the Asset section the file I uploaded does not show up in the folder created for the User ID. It's a blank folder. In fact the image doesn't show up anywhere in the Assets section. edit My bad, I hadn't created the folder for the asset. Thanks! Mar 27 '17 at 14:39
1

Stumbled across this looking for similar reason for error. Went with this in the end, as it adds some folder readability should I need to access uploads by user outside of the CP.

{% if fullName|length %}{fullName|lower}-{% endif %}{id}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.