authors (intermediate)
PmWiki can be configured to allow authors to upload and store files and images (known as attaching them). These attachments may then be referenced from any page.
Attach:
syntaxTo add or link to an attachment, an author edits a page to include the markup "Attach:
" followed by a name of an attachment (e.g., "Attach:resume.pdf
"). When the page is displayed, the Attach:
markup becomes one of the following:
The behavior of links can be modified to
[[Attach:image.jpg]]
).
Attach:
" at the beginning of the link, use [[(Attach:)file.ext]]
.
Attach:image.jpg"mouse over tool tip"
).
Attach:image.jpg"mouse over tool" | Caption text
).
To link to an uploaded attachment (image or file) from another group, you simply refer the group itself (make sure "Groupname" has the dot in it).
Attach:Groupname./file_name.ext
(note the dot after the groupname)
If PmWiki is configured with an individual directory per page use
Attach:Pagename/file_name.ext
(Pagename is in the same WikiGroup)
Attach:Groupname.Pagename/file_name.ext
To link to a filename with spaces in it use the bracket link notation, eg
[[Attach:a filename with spaces.txt]]
To embed an image with spaces or special characters escape them with the markup Attach:[=image name.jpg=]
.
See UploadsAdmin and $UploadNameChars
.
To list files that have been uploaded, use the directive (:attachlist:)
-- see PageDirectives#attachlist for more options.
This will list attachments to the current group or page, depending whether attachments are organized per group (default) or per page; each instance includes a link to the attachment for viewing or downloading. A list of attachments is also shown as part of the upload file form.
One can go directly to the upload form by appending "?action=upload" to the URI for any page that has file uploads enabled by the Wiki Administrator. Replace a file by simply uploading a new version of the file with the same name.
If you put
in your $EnableUploadVersions
=1;local/config.php
, the old versions of the same files are renamed and not removed.
For security reasons, the upload feature is disabled when PmWiki is first installed. When enabled uploads are restricted as to the types and sizes of files that may be uploaded to the server (see Uploads Admin). PmWiki's default configuration limits file sizes to 50 kilobytes and file extensions to common types of images, audio, video, and documents as shown below.
In addition, the administrator can configure the system to require an upload
password--see Passwords and Passwords Admin.
By default the upload feature allows the following extensions.
Category | Extensions |
---|---|
image files | gif, jpg, jpeg, png, bmp, ico, wmf, wbmp, xcf, webp, avif See Images for the files PmWiki automatically displays as images. |
audio | mp3, au, wav, ogg, flac, opus, m4a |
video | ogv, mp4, webm, mpg, mpeg, mov, qt, avi, mkv |
archives | zip, 7z, gz, tgz, rpm, hqx, sit |
office | pdf, odt, ods, odp, odg, doc, docx, ppt, pptx, xls, xlsx, mdb, rtf, csv |
executables | exe |
Adobe | psd, ps, ai, eps |
text files | txt, tex, dvi |
misc | kml, kmz |
At present uploaded files can only be deleted from the server by the wiki administrator. Any uploads-authorized user may over-write an existing file by uploading another of the same name and extension to the same location.
The administrator may remove an uploaded file by accessing the server via ftp (or via a control panel, if the host offers such a feature). The recipe Cookbook:Attachtable allows the deletion of the files from the wiki.
When I upload a file, how do I make the link look like "file.doc" instead of "Attach:file.doc Δ"?
Use parentheses, as in [[(Attach:)file.doc]]
. There is also a configuration change that can eliminate the Attach:
-- see Cookbook:AttachLinks.
Why can't I upload files of size more than 50kB to my newly installed PmWiki?
Out of the box PmWiki limits the size of files to be uploaded to 50kB. Add
$UploadMaxSize
= 1000000; # limit upload file size to 1 megabyte
Why does my upload exit unexpectedly with "Incomplete file received"?
You may be running out of space in a 'scratch' area, used either by PmWiki or by PHP. On *nix, check that you have sufficient free space in /tmp and /var/tmp.
How do I make it so that the upload link still allows one to make another upload (if someone wants to replace the old version of a file with a newer version, for example). Currently you only get the upload link when there is no file in the upload directory.
Use the Attach page action, and click on the delta symbol (Δ) shown against each of files listed. If you can't see the attach action either uploads are not enabled, you are not authorized to upload, or the attach action has been commented out or is missing. See also available actions.
How do I hide the " Attach:
" for all attachments
See Cookbook:AttachLinks, note that this does not currently work for [[Attach:my file.ext]]
.
How can I link a file that have a 4-letter file extension such like 'abc.pptx'?
How can I prevent others from using the url's of my images on their site
See Cookbook:Prevent Hotlinking
How can I display a file that lacks a correct extension? (e.g. you are using Cookbook:LinkIcons)
A file can be displayed by addition of a "false" extension to the URL. For example, if the url is https://example.com/dox/mydoc
, add a fake query string on the end with the desired extension (e.g., https://example.com/dox/mydoc?format=.docx
). If query strings are unsuitable, a fragment identifier should work, e.g. https://example.com/dox/mydoc#.docx
.
This page may have a more recent version on pmwiki.org: PmWiki:Uploads, and a talk page: PmWiki:Uploads-Talk.