AttachDelete

Summary: An enhancement to the current upload feature to allow the deletion of uploaded files.
Version: 0.08 21 Nov 2015
Prerequisites: Requires PmWiki version: 2.0; last tested on PmWiki version: 2.1 beta 12;
Status:
Maintainer:
Discussion: AttachDelete-Talk
Users: +1 (View / Edit)
Categories: Uploads

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 (:attachlist:) with (:newattachlist:).

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.

Notes

attachdel.phpΔ

Copy the attachdel.php to your cookbook folder. Add the line include_once('cookbook/attachdel.php'); to your local/config.php file

Releases

DateVersionNotes
14 Dec 20050.01Initial release, still testing
14 Dec 20050.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 20060.03Fixed a bug that occured when no files were selected when pressing delete. Thanks Peter for reporting this
23 Jan 20060.04ΔWas too quick to fix the previous problem and introduced more problems. All tested now and working properly.
24 Nov 20060.05Show upload input field after deleting an attachment (they were missing in older versions)
01 Aug 20080.06Fixed bug for filenames containing quotes + cosmetic changes
26 Feb 20090.07Added variable $IsAttachDeleteRecipeLoaded to allow

                 (:if enabled IsAttachDeleteRecipeLoaded:)
                 (:newattachlist:)
                 (:else:)
                 (:attachlist:)
                 (:ifend:)

                 in Site.UploadQuickReference 
21 Nov 20150.08replace Markup() with Markup_e() for php5.5 compatilbility
24 Mar 20170.09ΔFixes for pmwiki 2.2.93
01 Aug 20210.10ΔFixes for pmwiki 2.2.133 and PHP 7.4.20

See Also

Contributors

Dan Weber

Comments

See discussion at AttachDelete-Talk

User notes +1: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.