function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AlanisticAlanistic 

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
    {
        get
        {
            return currentChecklist.Attachments.get(0).Id;
        }
    }

 Any suggestions?

sfdcfoxsfdcfox
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.