#### Still need help?

The Atlassian Community is here for you.

This guide is for informational purposes and is not eligible for support from Atlassian.  If you have any questions about the information on this page, please reach out to our community at Atlassian Answers for help.

## Solution

Code Changes Required

This configuration requires changing the Confluence code in your installation. You will need to reapply these changes whenever you upgrade Confluence. Proceed with caution.

• Viewing the attachments for a page
• Viewing all the attachments for a Space (Browse > Attachments)

### Disable attachments for a whole Space

To disable downloading attachments from a Space, you need to edit the listattachmentsforspace.vm file. Delete or comment out the following line:

<td><a name="$!generalUtil.urlEncode($!attachment.content.displayTitle)-attachment-$!generalUtil.urlEncode($!attachment.fileName)">#parse ("/pages/includes/attachment_icon.vm")</a> <a href="$req.contextPath$!attachment.downloadPathWithoutVersion">$generalUtil.shortenString($attachment.fileName, 50)</a></td>


and replace it with either of the following two code blocks:

<td><a name="$!generalUtil.urlEncode($!attachment.content.displayTitle)-attachment-$!generalUtil.urlEncode($!attachment.fileName)">#parse ("/pages/includes/attachment_icon.vm")</a> $generalUtil.shortenString($attachment.fileName, 50)</td>


#set($disabledDownloads = ['ext1', 'ext2']) #set($disabled = false)
#set($attachmentExtension =$attachment.fileExtension)
<tr id="attachment_$!attachment.id"> #foreach($doNotDownload in $disabledDownloads) #if($attachmentExtension == $doNotDownload) #set($disabled = true)
#break
#end
#end
#if(!$disabled) <td><a name="$!generalUtil.urlEncode($!attachment.content.displayTitle)-attachment-$!generalUtil.urlEncode($!attachment.fileName)">#parse ("/pages/includes/attachment_icon.vm")</a> <a href="$req.contextPath$!attachment.downloadPathWithoutVersion">$generalUtil.shortenString($attachment.fileName, 50)</a></td> #else <td><a name="$!generalUtil.urlEncode($!attachment.content.displayTitle)-attachment-$!generalUtil.urlEncode($!attachment.fileName)">#parse ("/pages/includes/attachment_icon.vm")</a>$generalUtil.shortenString($attachment.fileName, 50)</td> #end  To specify which files you want disabled, change the  'ext1', 'ext2'  in the first line to the extensions for which you want to disable downloading. You can specify as many extensions as you want, as long as they are in quotes, are comma separated and do not include the '.' at the start. For example, if I did not want users to download .jpg and .doc and .png files, the line would read #set($disabledDownloads = ['jpg', 'doc', 'png'])


### Disable attachments for a specific page

If you take the steps in this section but not in the section above, the files you disable can still be downloaded by browsing all attachments for a Space.

To disable downloading attachments from a specific page, you need to edit the attachments-table.vm file. Delete or comment out the line

<a class="filename" href="$generalUtil.htmlEncode("${req.contextPath}${attachment.downloadPathWithoutVersion}")" title="$generalUtil.htmlEncodeAndReplaceSpaces($attachment.fileName)" >$generalUtil.htmlEncode($generalUtil.shortenString($attachment.fileName, 35))</a>


and replace it with either of the following two code blocks:

$generalUtil.htmlEncode($generalUtil.shortenString($attachment.fileName, 35))  #### Disabling downloading for specific file types #set($disabledDownloads = ['ext1', 'ext2'])
#set($disabled = false) #set($attachmentExtension = $attachment.fileExtension) #foreach($doNotDownload in $disabledDownloads) #if($attachmentExtension == $doNotDownload) #set($disabled = true)
#break
#end
#end
#if(!$disabled) <a class="filename" href="$generalUtil.htmlEncode("${req.contextPath}${attachment.downloadPathWithoutVersion}")" title="$generalUtil.htmlEncodeAndReplaceSpaces($attachment.fileName)" >$generalUtil.htmlEncode($generalUtil.shortenString($attachment.fileName, 35))</a> #else$generalUtil.htmlEncode($generalUtil.shortenString($attachment.fileName, 35))
#end


Again, to specify which files you want disabled, change the

 'ext1', 'ext2' 

in the first line to the extensions for which you want to disable downloading. You can specify as many extensions as you want, as long as they are in quotes, are comma separated and do not include the '.' at the start. For example, if I did not want users to download .jpg and .doc and .png files, the line would read

#set(\$disabledDownloads = ['jpg', 'doc', 'png'])


If you do not take the steps in this section, users will still be able to download all attachments regardless of whether they have been disabled or not.

1. Click, then General Configuration
2. Click Stylesheet, then the Edit button
3. Add the following to the Global Stylesheet

a.download-all-link {
display: none !important;
}
display: none !important;
}
4. Save

You can alternatively just disable Download All on a space by space basis by adding the above CSS to individual Space Stylesheets instead:

1. Go to the space and choose Space Tools > Look and Feel from the bottom of the sidebar
2. Choose Stylesheet then Edit.
3. Paste the above CSS into the text field.
4. Save

1. Go to Confluence 'gear' icon and click on 'General Configuration'
2. Go to 'Custom HTML'
3. Edit and insert the following code into the 'At end of the HEAD' section.
4. Save.

<style type="text/css">
display:none !important;
}

display:none !important;
}

display: none !important;
}

display: none !important;
}
</style>