2

I have a content type which consists of a large text field and a number of file fields. Users are allowed to /node/add instances of this content type and are then expected to upload all relevant files to their separate fields.

On disk I want to organize this so that all files end up inside one subdirectory unique for the node, so that I have a file structure:

.../sites/default/files/mycontenttype/
  node1/
    file1
    file2
    file3
  node2/
    file1
    file2
    file3

However, so far I haven't been able to find a value which is a) unique for a node and b) available at the point of adding the node.

I have tried:

  • [current-page:url:unaliased:path] (ends up as "/node/add/mycontenttype", ie the path for adding the node, not the path the node is about to get)
  • [random:number] (each field get a different random number)
  • [nid] (doesn't seem to be available, ends up as "%5bnid%5d")
  • [current-date:raw] (each field get a different time stamp unless they get uploaded exactly at the same time, ie files can't bee too large)

So question: How can I find a value which is guarranteed to be unique for a node at the point of running /node/add?

Your Answer

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

Browse other questions tagged or ask your own question.