Delete Attachment

Last modified by Eduard Moraru on 2020/06/03 15:14

cogProgrammatically delete an attachment from a document
Developed by

Oana Florea

0 Votes
LicenseGNU Lesser General Public License 2.1


Programming rights are needed in order to use deleteAttachment

#set ($myDoc = $xwiki.getDocument('Space.Document'))
#set ($attachmentName = 'myattachment.txt') ## delete the attachment with this name
#if ($myDoc.getAttachment($attachmentName))
  #set ($moveToRecycleBin = true) ## set this to false if low on space or you just don't want it moved to the recycle bin
  $myDoc.document.removeAttachment($myDoc.getAttachment($attachmentName).attachment, $moveToRecycleBin)

Prerequisites & Installation Instructions

Copy the code snippet to a page and save it.

Tags: development
Created by ElenaOanaTabaranu on 2009/07/08 18:43

Get Connected