2

I'm working on a feature that will allow me to create series of nodes. Each node will have a number of associated files. I'd like to be able to upload the files to a directory that uses some fields from the parent node. In other words, when the file is uploaded, a directory is used (or created if it doesn't exist yet) that uses the date the node was created and the title of the node. I know I can specify a static directory to use when creating a file field, but I need create a subdirectory inside the parent directory. Is this possible?

2 Answers 2

2

You can set the upload directory on the field settings for file fields.

By default the available tokens that can be used to create the directory are not that useful, because you can't use tokens for the node you just saved, for example.

To do that you can use the http://drupal.org/project/filefield_paths module.

It will allow you a much wider range of tokens. It also allows you to use tokens in the file name, as well as the directory.

0
3

If you look under your filefield settings you will see a field that called, “File directory” that is self-described as:

Optional subdirectory within the upload destination where files will be stored. Do not include preceding or trailing slashes. This field supports tokens.

You can use tokens. Something like. [current-date:short]/[current-page:title]

2
  • Hello. Do you know where can I find a list of these tokens?
    – Mołot
    Commented Oct 3, 2013 at 8:59
  • I usually just grab the ones I need in the pathauto alias patterns admin screen. In reality they should also be listed under the field settings. Maybe a good feature request for the token module. You can also view some more generic tokens at drupal.org/node/390482 Commented Oct 3, 2013 at 17:37

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.