Summary: Alternative file upload form using (:input file:)
Version: 2009-08-26
Prerequisites: pmwiki 2.2.3
Status: stable
Maintainer: HansB
Categories: Uploads PHP55

Questions answered by this recipe

How can I create an alternative to the default pmwiki upload page?

This section is optional; use it to indicate the types of questions (if any) this recipe is intended to answer.


UploadForm adds action 'postupload2' for use in alternative upload forms.

Installation: Download uploadform.phpΔ, copy to cookbook directory and install in config.php with:

Create an alternative upload form using Forms markup and the (:input file:) markup.

An example for a simple form (not enabled on this page):

(:if auth upload:)
(:input form enctype='multipart/form-data' action={*$PageUrl}:)
(:input hidden action postupload2:)
|| File to upload:||(:input file uploadfile size=50:) ||
|| Optionally rename file as:||(:input text upname size=50:) (:input submit post Upload:) ||
(:input end:)
(:else:)You need to login before you can upload [[{*$FullName}?action=login|login]](:if:) 

File to upload:
Optionally rename file as:

This form will keep the user on the page, and not redirect to the default uploads form. The script uses the standard file verification function. The form will display the upload result via the (:messages:) markup.

To show a list of uploaded files (attachments), use markup (:attachlist:), or for an alternative list with a tabulated, cleaner look use markup (:filelist:) (see FileList recipe for this).

Firefox drag-and-drop-files support

You can add support for drag-and-drop multiple files in Firefox by installing the dragdropupload Firefox extension.

To create an upload form which can handle multiple files dropped on it, build a form like this example:

(:input form enctype='multipart/form-data' action={*$PageUrl}:)
(:input hidden action postupload2:)
''This input box accepts multiple files dropped on it, which cannot be renamed''
|| File(s) to upload:||(:input dropfiles uploadfiles size=50:) ||
|| ||(:input submit post "Upload Files":) || 
(:input end:)

Note the file control is input dropfiles and its name is uploadfiles, not uploadfile. This makes it possible to have both forms of this type and of the single file input type shown first.


uploadform.php includes a modification of the HandlePostUpload function from scripts/upload.php.

Enssure that in config.php you secure the file upload action, ie

$DefaultPasswords['postupload2'] = crypt('secret');

Release Notes

  • 2009-08-26: Fixed bug so upload password gets checked.
  • 2007-09-03: Added support for drag-and-dropping multiple files (for Firefox which got the dragdropuploads extension installed). Improved message display of upload results.
  • 2007-09-01: initial release.

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".


  • 2009-08-25: Security problem... a non-priv user can upload files.
    Fixed now. HansB August 26, 2009, at 05:52 AM

See Also

  • DragDropMultiUpload Allow authors to upload files by simply dropping them into the wiki page
  • MultiUpload Upload multiple files at once by packing them in a zip archive & extracting them on the server


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.