Simple Way To Retrieve A Document Attachment In Kentico
- Published on
- -1 min read
If you are storing images or files using a “Direct Uploader” field type within a document and you need to retrieve them in your code, you have two options to get this file back:
- Read up on the Kentico API (DocumentHelper.GetAttachment() methods).
- Use Kentico’s “GetFile.aspx” page to reference the file itself.
As much as I would like to do things properly and familiarise myself with the Kentico API in greater detail, project time constraints can be a hindrance. In this case, I used the “GetFile.aspx” page in the following manner:
<img src="/CMSPages/GetFile.aspx?guid=<Attachment GUID>" title="My Kentico Image" />
The GUID for “Attachment GUID” will be found in the document where you use the “Direct Uploader” field.
I don’t know if this is what you would necessarily call a hack. But it works!
Before you go...
If you've found this post helpful, you can buy me a coffee. It's certainly not necessary but much appreciated!
Leave A Comment
If you have any questions or suggestions, feel free to leave a comment. I do get inundated with messages regarding my posts via LinkedIn and leaving a comment below is a better place to have an open discussion. Your comment will not only help others, but also myself.