%STARTINCLUDE% ---+ File Attachments %STARTSECTION{"attach:info"}%Each topic can have one or more files of any type attached to it by using the Attach screen to upload (or download) files from your local PC. Attachments are stored under revision control: uploads are automatically backed up; all previous versions of a modified file can be retrieved. %TOC% %STARTSECTION{"UserGuide"}% ---++ What are attachments good for? File Attachments can be used to archive data, or to create powerful customized groupware solutions, like file sharing and document management systems, and quick Web page authoring. ---+++ Document management system You can use Attachments to store and retrieve documents (in any format, with associated graphics, and other media files); attach documents to topics; collaborate on documents with full revision control; distribute documents on a [[#AttachmentAccess][need-to-know basis]] using web and topic-level access control; create a central reference library that's easy to share with an user group spread around the world. ---+++ File sharing For file sharing, FileAttachments on a series of topics can be used to quickly create a well-documented, categorized digital download center for all types of files: documents, graphics and other media, drivers and patches, applications; anything you can safely upload! ---+++ Web authoring Through your web browser, you can easily upload graphics (or sound files, or anything else you want to link to on a page) and place them on a single page, or use them across a web, or site-wide. <div class="foswikiHelp"> %H% You can also add graphics - any files - directly, typically by FTP upload. This requires FTP access, and may be more convenient if you have a large number of files to load. FTP-ed files cannot be managed using browser-based attachment controls. You can use your browser to create shortcuts using [[Macros]], like this %<nop>H% = %H%.</div> ---+++ Attachment Names Attachment names are stored directly in the server native file system, so filenames are sanitized to prevent use of names that would be unacceptable to the variety of platforms where Foswiki is supported. Note that the rules are different depending on whether or not your installation is configured to support international characters (!UseLocale) ---++++!! Default rules without international character set support. * Filenames must only be compose of: * "Mixed Alpha-Numeric" characters. (A-Z, a-z and 0-9) * May also contain: * ==.== (period / decimal point / "dot") * ==_== (Underscore) * ==-== (Hyphen or dash) * embedded spaces (Will be converted to underscore (==_==) during upload * Any other characters are removed from the filename. * Any leading dots or slashes (==.==, ==\== or ==/==) will be stripped * Embedded spaces will be converted to underscore ==_== * Certain filenames that might be interpreted as executable code will have .txt appended. (_This is set locally by your system administrator_) ---++++!! Attachment name rules with international character set support enabled. * Embedded spaces are converted to ==_== (Underscore). * Filenames are filtered according to rules set by your administrator. * The default rules will strip the following characters from the filename: * Any "whitespace" characters * ==*== (Asterisk) * ==?== (Question mark) * ==~== (Tilde) * ==^== (Caret / Circumflex) * ==\== (Backslash) * ==$== (Dollar-sign) * ==@== (At-sign) * ==%== (Percent-sign) * ==`'"== Quotes (Open-quote, Close-quote/Apostrophe, and Double-quote) * ==&== (Ampersand) * ==;== (Semicolon) * ==|== (Vertical line) * ==<>== (Less and Greater signs) * ==[]== (Open and close square brackets) * And any ASCII control characters (Hex x00-x1f) * Any leading dots or slashes (==.==, ==\== or ==/==) will be stripped * Certain filenames that might be interpreted as executable code will have .txt appended. (_This is set locally by your system administrator_) ---++ Uploading files * Click on the ==[Attach]== link at the bottom of the page. The =Attach= screen lets you browse for a file, add a comment, and upload it. The uploaded file will show up in the [[#FileAttachmentTable][file attachment table]]. <div class="foswikiHelp"> %H% The topic must already exist. If it does not, it is a two step process: First create the topic, then add the file attachment.</div> * Any type of file can be uploaded. Some files that might pose a security risk are renamed, for example: =*.php= files are renamed to =*.php.txt= so that no one can place code that would be read in a .php file. * Foswiki can limit the file size. This is defined by the =%<nop>ATTACHFILESIZELIMIT%= [[%SYSTEMWEB%.PreferenceSettings][preference settings]], currently set at %ATTACHFILESIZELIMIT% kB. <div class="foswikiHelp"> %X% It is not recommended to upload files greater than a few hundred K through a browser. Large files can be extremely slow-loading, and often time out. Use an FTP site for large file uploads.</div> * Automatic attachments: * When enabled, all files with valid names in a topic's attachment directory are shown as attachments to the topic - even if they were directly copied to the directory and never attached by using an =[Attach]= link. This is a convenient way to quickly "attach" files to a topic without uploading them one by one; although at the cost of losing audit trail and version control. * Before an attachment is shown, the filename is filtered per the above Attachment name rules. If the filtered name is not identical to the actual file name, the file will not be included in the list of attachments * To enable this feature, set the {AutoAttachPubFiles} configuration option. <div class="foswikiHelp"> %H% The automatic attachment feature can only be used by an administrator who has access to the server's file system.</div> * Linking to the attached file in the topic: * Checking the "Create a link to the attached file" appends a link at the end of the topic. The format can be modified with the =%<nop>ATTACHEDFILELINKFORMAT%= [[%SYSTEMWEB%.PreferenceSettings][preference setting]]. Images (files ending in gif, jpg, jpeg or png) are handled by =%<nop>ATTACHEDIMAGEFORMAT%=. * The two named preference settings may use the following variables: * =$filename=: the name of the file * =$fileext=: the filename extension (string following the last period, if present) or an empty string. * =$fileurl=: URL encoded version of the filename * =$comment=: the file comment from the upload dialog * =$size=: the filesize (=%<nop>ATTACHEDIMAGEFORMAT%= only) * Any standard [[FormatTokens][formatting tokens]]: =$n=, =$comma=, =$lt=, etc. * Any standard [[VarGMTIME][time format specifiers]]: =$year=, =$hours=, etc. * =$name=: (deprecated, should no longer be used) ---++ Downloading files * Click on the file in the [[#FileAttachmentTable][File Attachment table]]. #AttachmentAccess <div class="foswikiHelp"> %X% There is no access control on individual attachments. If you need control over single files, create a separate topic per file and set topic-level [[CompleteDocumentation#AccessControl][access restrictions]] for each.</div> ---++ Moving attachment files An attachment can be moved between topics. * Click ==[Manage]== on the Attachment to be moved. * On the control screen, select the new web and/or topic. * Click ==[Move]==. The attachment and its version history are moved. The original location is stored as [[CompleteDocumentation#Meta_Data_Definition][topic meta data]]. ---++ Deleting attachments Move unwanted Attachments to web =Trash=, topic =TrashAttachment=. ---++ Linking to attached files * Once a file is attached it can be referenced in the topic. Example: 1. ==[Attach]== a file, for example: =Sample.txt= 1. ==[Edit]== the topic you attached the file to and enter: =%<nop>ATTACHURL%/Sample.txt= 1. ==[Preview]==: the =%<nop>ATTACHURL%/Sample.txt= text appears as: %PUBURL%/%WEB%/%TOPIC%/Sample.txt, a link to the text file. * To reference an attachment located in another topic, enter: * =%<nop>PUBURL%/%<nop>WEB%/OtherTopic/Sample.txt= (if it's within the same web) * =%<nop>PUBURL%/Otherweb/OtherTopic/Sample.txt= (if it's in a different web) * Attached HTML files and text files can be inlined in a topic. Example: 1. ==[Attach]== file: =Sample.txt= 1. ==[Edit]== topic and write text: =%<nop>INCLUDE{"%<nop>ATTACHURL%/Sample.txt"}%= * Content of attached file is shown inlined. * [[VarINCLUDE][Read more about INCLUDE]]. * GIF, JPG and PNG images can be attached and shown embedded in a topic. Example: 1. ==[Attach]== an image file, for example: =Smile.gif= 1. ==[Edit]== topic and write text: =%<nop>ATTACHURL%/Smile.gif= 1. ==[Preview]==: text appears as %PUBURLPATH%/%WEB%/%TOPIC%/Smile.gif, an image. ---++ Securing Attachments In most installations, attachments are not secured. Anyone can read them if they know the name of the web, topic and attachment. To secure attachments, you have to control access to the attachments through the =viewfile= script, which requires a change in your web server configuration. To see how to configure Apache to do this, see https://foswiki.org/Support/ApacheConfigGenerator#Attachments %ENDSECTION{"attach:info"}% ---++ Examples Following you will find some examples of screens and tables related to this topic and referenced throughout the previous text. The appearance of these tables might vary, depending on what [[Skins][skin]] is used on your Foswiki installation. #FileAttachmentTable ---+++ File attachment table Files attached to a topic are displayed in a directory table, showing the different file names and attributes. An =h= means the attachment is hidden and not listed when viewing a topic in normal mode. The file attachment table is normally displayed at the bottom of the page, or optionally, hidden and accessed when you click =[Attach]=. <div class="foswikiAttachments"> <table summary="Topic attachments" style="border-width:1px;" cellspacing="0" id="foswikiAttachmentsTable" cellpadding="0" class="foswikiTable" rules="rows" border="1"> <caption>Topic attachments</caption> <tr class="foswikiTableEven"> <th style="text-align:center;vertical-align:middle;" class="foswikiFirstCol"> <a rel="nofollow" href="#FileAttachmentTable" title="Sort by this column">I</a> </th> <th style="text-align:center;vertical-align:middle;"> <a rel="nofollow" href="#FileAttachmentTable" title="Sort by this column">Attachment</a> </th> <th style="text-align:center;vertical-align:middle;"> <a rel="nofollow" href="#FileAttachmentTable" title="Sort by this column">Action</a> </th> <th style="text-align:center;vertical-align:middle;"> <a rel="nofollow" href="#FileAttachmentTable" title="Sort by this column">Size</a> </th> <th style="text-align:center;vertical-align:middle;"> <a rel="nofollow" href="#FileAttachmentTable" title="Sort by this column">Date</a> </th> <th style="text-align:center;vertical-align:middle;"> <a rel="nofollow" href="#FileAttachmentTable" title="Sort by this column">Who</a> </th> <th style="text-align:center;vertical-align:middle;"> <a rel="nofollow" href="#FileAttachmentTable" title="Sort by this column">Comment</a> </th> </tr> <tr class="foswikiTableOdd"> <td style="text-align:center;vertical-align:top;" class="foswikiFirstCol"> <img width="16" alt="txt" align="top" src="%PUBURL%/%SYSTEMWEB%/DocumentGraphics/txt.gif" height="16" border="0" /><span class="foswikiHidden">txt</span> </td> <td style="text-align:left;vertical-align:top;"> <a href="#FileAttachmentTable">Sample.txt</a> </td> <td style="text-align:left;vertical-align:top;"> <a href="#FileAttachmentTable" title='change, update, previous revisions, move, delete...'rel='nofollow'>manage</a> </td> <td style="text-align:right;vertical-align:top;"> <nop>0.1 K </td> <td style="text-align:left;vertical-align:top;"> <nop>22 Jul 2000 - 19:37 </td> <td style="text-align:left;vertical-align:top;"> <a href="#FileAttachmentTable">ProjectContributor</a> </td> <td style="text-align:left;vertical-align:top;"> Just a sample </td> </tr> <tr class="foswikiTableEven"> <td style="text-align:center;vertical-align:top;" class="foswikiFirstCol foswikiLast"> <img width="16" alt="gif" align="top" src="%PUBURL%/%SYSTEMWEB%/DocumentGraphics/gif.gif" height="16" border="0" /><span class="foswikiHidden">gif</span> </td> <td style="text-align:left;vertical-align:top;" class="foswikiLast"> <a href="#FileAttachmentTable">Smile.gif</a> </td> <td style="text-align:left;vertical-align:top;" class="foswikiLast"> <a href="#FileAttachmentTable" title='change, update, previous revisions, move, delete...'rel='nofollow'>manage</a> </td> <td style="text-align:right;vertical-align:top;" class="foswikiLast"> <nop>0.1 K </td> <td style="text-align:left;vertical-align:top;" class="foswikiLast"> <nop>22 Jul 2000 - 19:38 </td> <td style="text-align:left;vertical-align:top;" class="foswikiLast"> <a href="#FileAttachmentTable">ProjectContributor</a> </td> <td style="text-align:left;vertical-align:top;" class="foswikiLast"> Smiley face </td> </tr> </table></div><!--//foswikiAttachments--> #FileAttachmentControls ---+++ File attachment controls Clicking on a ==[Manage]== link takes you to a new page that looks a bit like this (depending on what [[Skins][skin]] is selected). Here, you have different options: * *To update an existing file*, choose the updated file on your local drive and click ==[Update file]==. The filename of the original attachment will preserved; the filename of the local file you chose will *not* be used. * *To change the comment* on an attachment, enter a new comment and then click ==[Change comment and properties only]==. Note that the comment listed against the specific version will not change, however the comment displayed when viewing the topic does change. * *To hide/unhide* an attachment, enable the ==Do not show attachment in table== checkbox, then click ==[Change comment and properties only]==. <div class="foswikiFormSteps"> <div class="foswikiFormStep"> <h3><a name="Attach_new_file"></a> Attach new file </h3> <p /> Select a new local file to update attachment <code>Sample.txt</code> <br />Upload up to 10000 KB. <p /> <input class="foswikiInputField" type="file" name="filepath" value="Sample.txt" size="30" /><input type="hidden" name="filename" value="Sample.txt" /> </div><!-- /foswikiFormStep--> <div class="foswikiFormStep"> <h3><a name="Comment"></a> Comment </h3> <p /> Describe the file so other people know what it is. <p /> <input class="foswikiInputField" type="text" name="filecomment" value="Just a sample" maxlength="256" size="50" /> </div><!-- /foswikiFormStep--> <div class="foswikiFormStep"> <h3><a name="Properties"></a> Properties </h3> <p /> <input type="checkbox" class="foswikiCheckbox" id="createlink" name="createlink" /><label for="createlink">Create a link to the attached file</label> <span class="foswikiGrayText">Images will be displayed, for other attachments a link will be created.</span> <p /> <input type="checkbox" class="foswikiCheckbox" id="hidefile" name="hidefile" /><label for="hidefile">Do not show attachment in table</label> <span class="foswikiGrayText">Attachments will not be shown in topic view page.</span> </div><!-- /foswikiFormStep--><div class="foswikiFormStep foswikiLast"><input type="submit" class="foswikiButton" name="changeproperties" value='Change comment and properties only' /></div><!-- /foswikiFormStep--> </div><!-- /foswikiFormSteps--> <a name="topic-actions"> </a><div class="patternTopicActions"><div class="patternTopicAction" style="margin-top:-1px;"><span class="patternActionButtons"> <input type="submit" class="foswikiSubmit" value='Upload file' /> or <a href="#FileAttachmentControls" title='Back to topic' accesskey='c' rel='nofollow'><span class='foswikiAccessKey'>C</span>ancel</a></span></div></div><!--/patternTopicActions--> %ENDSECTION{"UserGuide"}% %STOPINCLUDE% --- *Related Topics:* UserDocumentationCategory
Attachments
2
Attachments
2
I
Attachment
Action
Size
Date
Who
Comment
txt
Sample.txt
manage
30 bytes
09 Mar 2016 - 04:04
ProjectContributor
Just a sample
gif
Smile.gif
manage
94 bytes
09 Mar 2016 - 04:04
ProjectContributor
Smiley face
This topic: System
>
Category
>
UserDocumentationCategory
>
FileAttachment
Topic revision:
09 Mar 2016,
ProjectContributor
(raw view)
Copyright © by the contributing authors. All material on this site is the property of the contributing authors.
Ideas, requests, problems regarding Iris Wiki?
Send feedback