Remove files that are not PDF, XLS, DOC, or PNG filetypes after they are uploaded

This script can be used for file type restriction

import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.confluence.pages.AttachmentManager
def attachmentManager = ComponentLocator.getComponent(AttachmentManager)
def attachment = event.getAttachment()

if (attachment.getFileExtension() != "pdf"||"xls"||"doc"||"png")
{
attachmentManager.removeAttachmentFromServer(attachment)
}