I am trying to download attachment from link :

<a href="{!'/servlet/servlet.FileDownload?file='+attachment.Id}" target="_blank">{!attachment.name}</a>

but the attachment is being downloaded as type "file". I have tried to append Content Type with file name while saving the file but it doesn't seem to be working. Any suggestions would be appreciated. p.s - a question is already asked on similar topic (click here) but answers were not helpful.

1 Answer 1


Use the "download" attribute, provide the filename of the attachment there (make sure it includes the extension).

<a href="{!'/servlet/servlet.FileDownload?file='+attachment.Id}" download="{!attachment.name}" target="_blank">{!attachment.name}</a>

"download" attribute info: https://www.w3schools.com/tags/att_a_download.asp

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .