Friday, September 27, 2013

Direct download an attachment from a link in Visualforce page

In many cases we need to download a file instead of opening the same.

 A simple HTML5 trick to do the same like below



{!attachment.name}

(this will simply open the file)

 


here main attributes are we should have docType="html-5.0" and download="{!attachment.name}" for the respective components as highlighted above...


Here I used the standard controller you can construct the same using controllers/Extensions to achive the same.



Happy coding...........