Upload Files

Also available in Deutsch, Español, Française, Русский, 简体中文



Non-mandatory options and parameters are enclosed in [square brackets].
When using the actions please remove the square [ ] brackets from the parameters to make it work.
Numerical values are given without and strings with quotation marks, max=10 and page="PageName".

To display all available parameters of an action, use help=1 (e.g. {{upload help=1}} or {{files help=1}}).


1. Action

1.1. upload


  • Form for file upload to a page or into global space
  • Invoke: {{upload [global=0] [maxsize=200] [hide_description=0] [rename=0]}}
  • Parameters:
    • global — this option allows uploaded files to be globally available for all users. Default is 0 = the file is attached to the current page (local name space).
    • maxsize — forcibly limits the maximum size of the uploaded file. The value must be smaller than the configured maximum; it can only lower the limit, never raise it. The effective maximum shown in the form is the smaller of the configured maximum and this value.
    • hide_description — if set to 1, the text field "description" is not shown, there remains only the field for the file. Default is 0 = the description field is shown.
    • rename — if set to 1, an additional field for renaming the uploaded file is displayed (this option is not listed in the built-in help of the action).

  • Permissions: users who have neither read, write nor upload rights on the current page -- and who are not administrators -- are automatically switched to the global upload. If uploading is not allowed at all, the action displays the message "Upload forbidden" instead of the form.
  • File types: with the setting upload_images_only only image files (bitmap formats) can be uploaded; administrators are exempt from this restriction. With upload_allowed_exts the file selection is restricted to the listed extensions.

Note : Please keep in mind that files might be rejected based on other criteria, for example lack of disk space, because the file is larger than the maximum allowed file size or because your web-host does not allow particular files.


If you’d like to allow larger files, you’ll need to edit the PHP configuration file (php.ini) and add or set the following lines in php.ini (the example allows files up to 32 Mb):

INI
upload_max_filesize = 32M
post_max_size = 32M
max_execution_time = 300

Keep in mind that the wiki enforces its own limit independently of PHP: the effective maximum is derived from the configuration (upload_max_size) and can be lowered per call with maxsize.

1.2. files

  • shows uploaded files for a specific page or global space
  • Call: {{files [page="PageName"] [global=1] [all=1] [linked=1] [cluster=1] [order="name"] [form=1] [options=0] [owner="UserName"] [media=1] [max=Number] [nomark=0]}}
  • Parameters:
    • page — define the name of the page, from which the list of files is to be loaded. Without this parameter the files of the current page are listed.
    • global=1 — list of the global name space is shown.
    • all=1 — all attachments of the wiki are listed, including global files.
    • linked=1 — only the files that are linked from the current page.
    • cluster=1 — the attachments of all pages of the cluster (all subpages of the current page).
    • order — sort file list by file extension, time, name, size and their reverse order: ext, ext_desc, name_desc, size, size_desc, time, time_desc. Default is name (file name ascending).
    • form=1 — show the search form with a phrase field.
    • options — show sort & filter options (language, user, MIME type, categories).
    • owner — show files uploaded by a specific user.
    • media — parses image, audio and video links into their media tags — similar to a gallery. With this option wide images are additionally served as thumbnails (?450) when thumbnail creation is enabled.
    • max=Number — maximum number of files shown per page.
    • nomark — if set to 1, no border around the query result will be shown.
  • Additional filters are passed through the query string and are used by the form: ?phrase=..., ?lang=..., ?user_id=..., ?mime=..., ?category_id=..., ?type_id=..., ?dir=asc|desc, ?order=....
  • The read permission of the page a file belongs to is checked; files of pages that are not readable are omitted. Administrators, the owner of the page and the uploader of the file additionally get the file tools (show properties, edit properties, remove), which lead to the filemeta handler (?m=show|edit|remove&file_id=…).

2. Syntax of reference to the file

Local uploaded files, attached to a page, were check against the pages read permission.


The actions themselves generate the following forms:

  • file:/<Tag>/<filename> — media reference to a file attached to a page (used with media=1)
  • _file:/<Tag>/<filename> — plain link to a file attached to a page (used without media)
  • file:/<filename> — media reference to a file in the global name space
  • _file:/<filename> — plain link to a file in the global name space

2.1. URL syntax


  • https://example.com/file/global/archive.zip — file in the global name space
  • https://example.com/Dev/ToDo/Upload/file?get=archive.zip — file attached to a specific page
    • without rewrite-mode it looks like:
    • https://example.com/?page=Dev/ToDo/Upload/file&get=archive.zip
  • the *file* handler also accepts the parameter tbn=<width>x<height> for requesting a thumbnail of the given size (used by the gallery action).

2.2. Wacko syntax


  1. file:archive.zip - searches for local files that are only available to users who are allowed to read this page
  2. file:/archive.zip - only the global file
  3. file:!/archive.zip - for local file with relative path
  4. file:/Subpage/archive.zip - for local file with absolute path, necessary for local files to be included in another page

The absolute path is only needed if you want to embed a locally attached file in another page. This is rather rare, as the user usually embeds the file in the same page. In this case, the relative syntax should always be the preferred option, as it is not only shorter but also works after the page to which the file is attached has been renamed.

2.2.1. Media Parameters

Parameters are added to the file syntax by appending a question mark ? and adding additional parameters by an ampersand &.
e.g. file:/image.png?200x400&direct&caption


  • linking
    • direct - to file
    • nolink - shows only the image
    • linkonly - shows only link
    • meta - to filemeta handler (default)
  • alignment
    • right
    • left
    • center
  • resizing
    • 400x300 - width x height
    • 0x700 - height
    • 600 - width
  • others
    • caption - shows caption
    • clear - clears float

Note: the direct, nolink, linkonly, meta, alignment, resizing, caption and clear options are evaluated by the page formatter and not by the actions themselves; the only parameter produced by the files action is the thumbnail suffix ?450 (and the ?tbn=… parameter of the *file* handler used by the gallery action).


Example:
file:/Groups/WackoWiki/mammut_800.webp?500&caption

The Woolly Mammoth (Elephas primigenius)
We try to respect the hunter that dominated the first 99.9% of the history of our species. If you had to kill a mammoth or do without supper, there was no time to draw up an organization chart, assign tasks, or delegate authority. Basically, the person who saw the mammoth from farthest away was the Official Sighter, the one who ran fastest was the Head Runner, whoever threw the most accurate spear was the Grand Marksman, and the person all others respected most and listened to was the Chief. That’s all there was to it. Distributing little charts to produce an appearance of order would have been a waste of time. It still is.

2.3. Embedding media files

Media files are rendered in their media tag such as <image>, <audio> or <video> unless otherwise declared.


Lotus Flower
Shinobazu Pond at Ueno Park at Ueno, Taito-ku in Tokyo
(Source:: Yoshikazu TAKADA /Some rights reserved)

Sandhill Cranes
(Source:: NPS / Dale Bohlke /Public domain)

Johann Sebastian Bach - Well-Tempered Clavier, Book 1 - 01 Prelude No. 1 in C major, BWV 846
(Source:: Composer: Johann Sebastian Bach; Performer: Kimiko Ishizaka /Public domain)

3. File storage on server

Files for all users (global), directory UPLOAD_GLOBAL_DIR:
file/global/

graphics.png
letter.odt

Files of specific pages, directory UPLOAD_LOCAL_DIR, the page id is part of the file name:
file/perpage/

@[page_id]@picture.jpg
@[page_id]@handbook.pdf
@[page_id]@calculation.ods

Files after backup (admin panel), directory UPLOAD_BACKUP_DIR:
file/backup/


Thumbnails are stored separately: global thumbnails in THUMB_DIR, thumbnails of page files in THUMB_LOCAL_DIR. Both directories are purged by the admincache action.

4. Customize upload settings

4.1. Edit constants: config.php

constants.php

PHP
<?php
...
const UPLOAD_GLOBAL_DIR            = 'file/global';
const UPLOAD_LOCAL_DIR             = 'file/perpage';
const UPLOAD_BACKUP_DIR            = 'file/backup';
...

  • UPLOAD_GLOBAL_DIR — where are placed the public files
  • UPLOAD_LOCAL_DIR — where are placed files only for users allowed to view current page, attached to the concrete pages

4.2. Edit secondary config

The following settings are used by the upload and files actions (verified in the action sources):


config setting value description
upload true who can upload. Anonymous users cannot upload ever
attachments_handler 2 enables the upload section in the user profile
upload_images_only true if established, then it does not give to load something besides pictures. Pictures are determined with the aid of GD. Administrators are exempt
upload_allowed_exts
allowed file types; restricts the file selection of the upload form
upload_max_size
the maximum permissible size of the file (the value is interpreted by the configuration code; the upload form displays it in binary multiples)
upload_quota 0 is how much Byte can be uploaded at all (if it is not established, then as much as desired)
upload_quota_per_user 500000 is how much Byte can be uploaded by one user (if it is not established, then as much as desired)
create_thumbnail true creates thumbnails for wide images (?450) when the file list is shown as media
max_thumb_width
maximum width of the generated thumbnails (used by the gallery action)

The following settings belong to the upload handling as well, but are not referenced by the actions themselves (they are processed by the upload handler / configuration):


config setting value description
check_mimetype true check MIME type
default_upload_acl Admins who can upload. Anonymous users cannot upload ever
upload_translit true transliterate file names
upload_translit_lower false convert file names to lowercase
upload_banned_exts php, cgi, js, php, php3, php4, php5, ...

Note: the MIME type is stored with every file record. For records created before the MIME type was introduced, the type can be filled in afterwards with the adminupdate action; the files action can filter the list by MIME type.


attachment settings module

4.3. Page upload permissions

The page owner or admin can further restrict the file upload to a particular page via page permissions.


WackoWiki Permissions [access control lists]