I want each user's attachments (they will be school assignments docs, photos, maps) to be saved in user's own subfolder in order to be able to collect them easily and separately.

How would this made possible and what are the best modules to utilize in order to achieve it?

  • Can you explain your question further which version of Drupal? and how files are attached , is it using any modules or Drupal FAPI ?
    – shrish
    Mar 23, 2014 at 8:49
  • I am using Drupal 7! Files are attached by using a file field in a special content type called assignment.
    – Drupallar
    Mar 23, 2014 at 17:56
  • I have posted answer, you can try that method ! for configuration goto "content type" field settings and in the file path put the token value.
    – shrish
    Mar 23, 2014 at 17:59

2 Answers 2


In Drupal 7, the core File module and the Token module (https://drupal.org/project/token‎) will let you do this.

In the settings for your file field, specify a file directory using a user token. I recommend prefacing the token'd directory with users/ (or something) so that you can easily find all of these files separate from other files on the site.

For example to use the user ID as the directory, set the 'file directory' to


You can see all the user-related tokens available to you on your site at admin/help/token.

  • When you say settings of the file field you mean at the file field of a particular content type. right?
    – Drupallar
    Mar 23, 2014 at 18:00
  • I get the following error when I try the users/[user:uid] solution. File directory is using the following invalid tokens: [user:uid].
    – Drupallar
    Mar 23, 2014 at 19:08
  • Install the filefield module..you will get those token available to choose from.
    – shrish
    Mar 24, 2014 at 2:00
  • Well that's embarrassing. 1. Yes, it looks like you are putting the token in the right place. 2. It looks like the file module will support [current-user:uid] but not [user:uid]. n.b. The filefield module is for Drupal 6.
    – calebtr
    Mar 29, 2014 at 2:31

filefield and Token module can do it, nice and clean.

The File (Field) Paths module extends the default functionality of Drupal's core Upload module, the FileField module and many other File Upload modules by adding the ability to use node tokens in destination paths and filenames.

In simple terms, File (Field) Paths allows you to automatically sort and rename your uploaded files using token based replacement patterns to maintain a nice clean filesystem.

  • Can I use it even if some users already uploaded content?
    – Drupallar
    Mar 23, 2014 at 17:59
  • nope! this will be applied only after the settings are submitted.
    – shrish
    Mar 23, 2014 at 18:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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