Questions answered by this recipe
An enhancement to the current upload feature to allow the deletion of uploaded files.
This cookbook entry creates a new markup
(:newattachlist:) which includes a delete link for each file listed. The user needs to have upload permission to see the link and the associated action delattach requires upload permission as well.
If you want to replace the standard list PmWiki uses for the upload action you have to edit the page
Site.UploadQuickReference and replace
This is my first PmWiki extension and I am still learning how to properly write those enhancements. Feedback is highly encouraged so I can learn.
I don't want to forget to mention that the base code for this script was taken from the standard upload.php script. Maybe down the road this could be integrated with the core upload.php script.
Copy the attachdel.php to your cookbook folder. Add the line
include_once('cookbook/attachdel.php'); to your
|14 Dec 2005||0.01||Initial release, still testing|
|14 Dec 2005||0.02||* Changed delete actions from a get URL to a post form|
* Multiple Files can be deleted at once
* File names go through a very basic validation filter
|17 Jan 2006||0.03||Fixed a bug that occured when no files were selected when pressing delete. Thanks Peter for reporting this|
|23 Jan 2006||0.04Δ||Was too quick to fix the previous problem and introduced more problems. All tested now and working properly.|
|24 Nov 2006||0.05||Show upload input field after deleting an attachment (they were missing in older versions)|
|01 Aug 2008||0.06||Fixed bug for filenames containing quotes + cosmetic changes|
|26 Feb 2009||0.07||Added variable $IsAttachDeleteRecipeLoaded to allow|
(:if enabled IsAttachDeleteRecipeLoaded:) (:newattachlist:) (:else:) (:attachlist:) (:ifend:) in Site.UploadQuickReference
|21 Nov 2015||0.08||replace Markup() with Markup_e() for php5.5 compatilbility|
|24 Mar 2017||0.09Δ||Fixes for pmwiki 2.2.93|
See discussion at AttachDelete-Talk