1

I just learned about the creating fields and content types and had a quick question about the file field. When you create a file field you can specify a relative path that the uploaded resource will be stored by entering a path in the "File Directory" text field, but what I am going to need is to have the value be different depending on the circumstances. For example I might want to clump all of the files uploaded by a certain user so I might want the relative path to depend on the user's name. Is there a way to specify this type of dynamic path? Is the something people normally do? Or would they just organize files based on type?

2 Answers 2

3

It's very easy if you have the Token module installed. On the file field edit page you'll see something like this:

enter image description here

The big table is a list of tokens that you can use in the path for the file. By default there are tokens available for current user, current page, current date and a couple of others.

For example you could have a path such as users/[current-user:name], in which the token would be substituted for the current user's name. You just need to click in the text box you want to add the token to and then click the links in the table, it will auto-fill for you.

Hope that helps

0
1

I think you may try filefield paths module which extends Token and gives you more interesting options like [node:nid].

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.