3

I'm trying to figure out how to print out the file path and the name of the file uploaded from a custom content type. I have my template all setup and everything printing how I need to, the last thing is I just need to be able to print out the path or at least the name of the file from the upload attached to the content.

I tried using:

{{ node.field_name.value }}
{{ node.field_name.url }}
{{ node.field_name.content }}
4

The file field is an entity reference field, you can get the first file entity with .entity:

{{ node.field_downloads.entity.filename.value }}
{{ node.field_downloads.entity.uri.value }}

And access the fields of the file entity as usually.

If you have more than one file in the field:

second file:
{{ node.field_downloads.1.entity.filename.value }}
third file:
{{ node.field_downloads.2.entity.filename.value }}
1
  • Thank you very much! You helped me yesterday too, I figured out a lot but this was one of the last things I couldn't seem to find Dec 5 '15 at 10:11

Your Answer

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

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