+ Start a Discussion

Force a link to use save as for the attachment instead of open in browser

We have an object that allows users to upload files.  A lot of these files are XML files and so they will naturally open in the browser.  


I want to force these to offer a "save as" dialogue instead of opening in the browser.  Can anyone advise on the best way?


The code for the actual download link is below:


<a href="/servlet/servlet.FileDownload?file={!AttachmentId}" target="_blank" onclick="IncrementDL()">

 The attachmentid is quite straight forward:


public String AttachmentId
            return currentChecklist.Attachments.get(0).Id;

 Any suggestions?

You can't control a browser's actions for saving a file. That's dependent on the browser's configuration. For example, if the browser is Chrome, a PDF file will display in the browser directly.