Drupal Views - Linking to a File Path

If you are using Drupal, the chances are you probably are using Views/CCK as well. I recently came up against a problem where I couldn't link to the path of an attached file to a Views display. This is where the Relationships feature comes in. This allows us to find additional information linked to the node - in this case, the filepath.

First goto Relationships and add Upload: Attached Files as a new Relationship. Next goto the Field section and add (Files) File: Path as a new field, remembering to choose Exclude from display. This means we can still use the data without displaying the field. Also make sure this field comes first in the ordering.

Finally add the Field with which you want to use the filepath and choose Output this field as a link. Here you will be able to use the replacement pattern [filepath].