[pmwiki-users] $UploadPrefixFmt and Attach files

Hans design5 at softflow.co.uk
Sun Apr 6 04:55:15 CDT 2008

I have put together a script which enables use of a $UploadPrefix
array to set upload prefixes individually for groups or pages.
This contains  modified versions of a few upload functions and
redefines action=postupload and action=download to use these
functions. It works in addition to the upload.php script.

I did not see the need to duplicate upload.php completely, just to
introduce the modified parts as a recipe. The modifications are not
very big. Chiefly I added a small MakeUploadPrefix function which
checks the $UploadPrefix array to build the upload prefix as needed.
Perhaps the modifications can be incorporated some day in the core
upload.php script, but you can use them as recipe now.

See http://www.pmwiki.org/wiki/Cookbook/UploadPlus

This script adds additonal features to the upload capabilities of PmWiki.

1. It allows uploads to be organised by Group and by Group/Name/ subfolders as
   required for different groups, by setting an array $UploadPrefix, instead of
   using $UploadPrefixFmt, i.e.'Special' group uploads organised in subfolders
   per page:
      $UploadPrefix['Special'] = '/$Group/$Name';
2. Attach:filename.ext if shown as link appears without the Attach: part.
3. Setting $EnableLinkPrefixLabel = 1; will display links with Attach:filename
   part (default is filename only without prefix label).
4. File list (:attachlist:) is tabulated (adapted from Cookbook:FileList).

As this is a recipe I did not wish to confuse names, so I did not use
$UploadPrefixFmt as the array name, but called it $UploadPrefix.
The recipe script will use an $UploadPrefixFmt value if this is
set, as the default.

* $UploadPrefix['default'] = '/$Group/$Name'; - All file
  attachments will be stored in GroupName/PageName/ subdirectories of the
  uploads directory (default is '/$Group', one subdirectory per group).
* $UploadPrefix['Special'] = '/$Group/$Name'; - Files attached to
  pages in the Special group will be stored in one subdirectory per page.
* $UploadPrefix['Test.ABC'] = '/Test/ABC001'; - Files attached to
Test.ABC will be stored in subdirectory Test/ABC001.

I tested this in various configurations, for various UploadPrefix
settings, and for page includes, and it seems to behave well.

Comments, suggestions, feedback most welcome!
Oh, and  a new Fox version will follow with an updated FoxPostUpload
function to enable the upload prefix enhancements for Fox upload


More information about the pmwiki-users mailing list