Sitefinity 3.2 comes with an "Images & Documents Module". This module makes it easy to create & manage libraries of images, files & documents on your web site. I found this module to be a much easier than using FTP to manage my web site's files.
Using Images & Documents in your Sitefinity Pages
Once a file is uploaded via the Images & Documents Module, Sitefinity creates a unique URL for accessing the file. Example: http://www.goondocks.com/Libraries/Havasu%20Falls/before-the-falls.sflb
You can then insert a static anchor link into your web page to link to the file.
I wanted to go a step beyond this however. Rather than inserting a static link to my file, I wanted to place a control on my page that could be associated with a previously uploaded file. This method has the following advantages:
- The control-to-file association is based on an ID, not a URL. If the file name is changed, the URL will also change. This would cause a static link to break. By using an ID association, the control dynamically updates the URL and the association remains intact.
- The control can render dynamic information about the underlying file (file type, file size, date created, date modified). You could statically reproduce all of this information in the page, but it would become outdated quickly.
To accomplish this I created a new Sitefinity "File Link" control. This control can be dropped onto any Sitefinity page. Once placed the "File Link" control can be associated with any existing file uploaded via the "Images & Documents Module". When the file association is in-place the control will render a "Download Box".
How To Use the "File Link" Control
- Drop the "File Link" control onto your Sitefinity page.
- Dropping the Sitefinity File Link Control onto a page.
- Edit the "File Link" control and select the Images & Documents file you wish to associate with the control: Configuring the Sitefinity File Link Control
- Click "I'm Done" and you now have a fully dynamic download-box for your file: Sitefinity File Link Control placed on a page.