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)
}