(no commit message)
[openafs-wiki.git] / TWiki / FileAttachment.mdwn
1 # <a name="File Attachments"></a> File Attachments
2
3 _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._
4
5 <div>
6   <ul>
7     <li><a href="#File Attachments"> File Attachments</a><ul>
8         <li><a href="#What Are Attachments Good For?"> What Are Attachments Good For?</a><ul>
9             <li><a href="#Document Management System"> Document Management System</a></li>
10             <li><a href="#File Sharing"> File Sharing</a></li>
11             <li><a href="#Web Authoring"> Web Authoring</a></li>
12           </ul>
13         </li>
14         <li><a href="#Uploading Files"> Uploading Files</a></li>
15         <li><a href="#Downloading Files"> Downloading Files</a></li>
16         <li><a href="#Moving Attachment Files"> Moving Attachment Files</a></li>
17         <li><a href="#Deleting Attachments"> Deleting Attachments</a></li>
18         <li><a href="#Linking to Attached Files"> Linking to Attached Files</a></li>
19         <li><a href="#File Attachment Contents Table"> File Attachment Contents Table</a></li>
20         <li><a href="#File Attachment Controls"> File Attachment Controls</a><ul>
21             <li><a href="#Attach new file"> Attach new file </a></li>
22             <li><a href="#Comment"> Comment </a></li>
23             <li><a href="#Properties"> Properties </a></li>
24           </ul>
25         </li>
26         <li><a href="#Known Issues"> Known Issues</a></li>
27       </ul>
28     </li>
29   </ul>
30 </div>
31
32 ## <a name="What Are Attachments Good For?"></a> What Are Attachments Good For?
33
34 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.
35
36 ### <a name="Document Management System"></a> Document Management System
37
38 - You can use Attachments to store and retrieve documents (in any format, with associated graphics, and other media files); attach documents to specific TWiki topics; collaborate on documents with full revision control; distribute documents on a [[need-to-know basis|Main/WebHome#AttachmentAccess]] 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.
39
40 ### <a name="File Sharing"></a> File Sharing
41
42 - 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!
43
44 ### <a name="Web Authoring"></a> Web Authoring
45
46 - 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.
47   - **_NOTE:_** 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 can't be managed using browser-based Attachment controls. You can use your browser to create [[TWikiVariables]] shortcuts, like this %H% = %H%.
48
49 ## <a name="Uploading Files"></a> Uploading Files
50
51 - Click on the <code>**Attach**</code> 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 [[File Attachment table|Main/WebHome#FileAttachmentTable]].
52   - **_NOTE:_** The topic must already exist. It is a two step process if you want to attach a file to a non-existing topic; first create the topic, then add the file attachment.
53   - Any type of file can be uploaded. Some files that might pose a security risk are renamed, ex: `*.php` files are renamed to `*.php.txt` so that no one can place code that would be read in a .php file.
54   - The previous upload path is retained for convenience. In case you make some changes to the local file and want to upload it, again you can copy the previous upload path into the Local file field.
55   - TWiki can limit the file size. This is defined by the `%ATTACHFILESIZELIMIT%` variable of the [[TWikiPreferences]], currently set at %ATTACHFILESIZELIMIT% KB.
56     - %X% It's 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.
57 - Automatic attachments:
58   - When enabled, all files 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.
59   - To enable this feature, set the \{AutoAttachPubFiles\} configuration option.
60   - **_NOTE:_** The automatic attachment feature can only be used by an administrator who has access to the server's file system.
61
62 ## <a name="Downloading Files"></a> Downloading Files
63
64 - Click on the file in the [[File Attachment table|Main/WebHome#FileAttachmentTable]].
65
66 <a name="AttachmentAccess"></a>
67
68 - %X% _NOTE:_ 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 [[access restrictions|Main/TWikiDocumentation#TWikiAccessControl]] for each.
69
70 ## <a name="Moving Attachment Files"></a> Moving Attachment Files
71
72 An attachment can be moved between topics.
73
74 - Click <code>**Manage**</code> on the Attachment to be moved.
75 - On the control screen, select the new web and/or topic.
76 - Click <code>**Move**</code>. The attachment and its version history are moved. The original location is stored as [[topic Meta Data|Main/TWikiDocumentation#Meta_Data_Definition]].
77
78 ## <a name="Deleting Attachments"></a> Deleting Attachments
79
80 Move unwanted Attachments to web `Trash`, topic `TrashAttachment`.
81
82 ## <a name="Linking to Attached Files"></a> Linking to Attached Files
83
84 - Once a file is attached it can be referenced in the topic. Example:
85   1. <code>**Attach**</code> file: `Sample.txt`
86   2. <code>**Edit**</code> topic and enter: `%ATTACHURL%/Sample.txt`
87   3. <code>**Preview**</code>: `%ATTACHURL%/Sample.txt` text appears as: <http://www.dementia.org/twiki//view/%WEB%/%TOPIC%/Sample.txt>, a link to the text file.
88
89 - To reference an attachment located in another topic, enter:
90   - `%PUBURLPATH%/%WEB%/OtherTopic/Sample.txt` (if it's within the same web)
91   - `%PUBURLPATH%/Otherweb/OtherTopic/Sample.txt` (if it's in a different web)
92
93 - Attached HTML files and text files can be inlined in a topic. Example:
94   1. <code>**Attach**</code> file: `Sample.txt`
95   2. <code>**Edit**</code> topic and write text: `%INCLUDE{"%ATTACHURL%/Sample.txt"}%`
96     - Content of attached file is shown inlined.
97     - Read more about INCLUDE in [[TWikiVariables|Main/VarINCLUDE]]
98
99 - GIF, JPG and PNG images can be attached and shown embedded in a topic. Example:
100   1. <code>**Attach**</code> file: `Smile.gif`
101   2. <code>**Edit**</code> topic and write text: `%ATTACHURL%/Smile.gif`
102   3. <code>**Preview**</code>: text appears as ![Smile.gif](http://www.dementia.org/twiki//view/%WEB%/%TOPIC%/Smile.gif), an image.
103
104 <a name="FileAttachmentTable"></a>
105
106 ## <a name="File Attachment Contents Table"></a> File Attachment Contents Table
107
108 Files attached to a topic are displayed in a directory table, displayed at the bottom of the page, or optionally, hidden and accessed when you click **Attach**.
109
110 <div>
111   <table border="1" cellpadding="0" cellspacing="0" id="twikiAttachmentsTable" rules="rows" style="border-width: 1px" summary="Topic attachments">
112     <caption>Topic attachments</caption>
113     <tr>
114       <th align="center" bgcolor="#ffffff" style="text-align: center; vertical-align: middle" valign="middle"><a href="%TOPIC%?sortcol=0;table=1;up=0#sorted_table" rel="nofollow" title="Sort by this column"><font color="#0066cc">I</font></a></th>
115       <th align="center" bgcolor="#ffffff" style="text-align: center; vertical-align: middle" valign="middle"><a href="%TOPIC%?sortcol=1;table=1;up=0#sorted_table" rel="nofollow" title="Sort by this column"><font color="#0066cc">Attachment</font></a></th>
116       <th align="center" bgcolor="#ffffff" style="text-align: center; vertical-align: middle" valign="middle"><a href="%TOPIC%?sortcol=2;table=1;up=0#sorted_table" rel="nofollow" title="Sort by this column"><font color="#0066cc">Action</font></a></th>
117       <th align="center" bgcolor="#ffffff" style="text-align: center; vertical-align: middle" valign="middle"><a href="%TOPIC%?sortcol=3;table=1;up=0#sorted_table" rel="nofollow" title="Sort by this column"><font color="#0066cc">Size</font></a></th>
118       <th align="center" bgcolor="#ffffff" style="text-align: center; vertical-align: middle" valign="middle"><a href="%TOPIC%?sortcol=4;table=1;up=0#sorted_table" rel="nofollow" title="Sort by this column"><font color="#0066cc">Date</font></a></th>
119       <th align="center" bgcolor="#ffffff" style="text-align: center; vertical-align: middle" valign="middle"><a href="%TOPIC%?sortcol=5;table=1;up=0#sorted_table" rel="nofollow" title="Sort by this column"><font color="#0066cc">Who</font></a></th>
120       <th align="center" bgcolor="#ffffff" style="text-align: center; vertical-align: middle" valign="middle"><a href="%TOPIC%?sortcol=6;table=1;up=0#sorted_table" rel="nofollow" title="Sort by this column"><font color="#0066cc">Comment</font></a></th>
121     </tr>
122     <tr>
123       <td align="center" bgcolor="#ffffff" style="text-align: center; vertical-align: top" valign="top"><img align="top" alt="txt" border="0" height="16" src="http://www.dementia.org/twiki//view/%SYSTEMWEB%/TWikiDocGraphics/txt.gif" width="16" /><span>txt</span></td>
124       <td align="left" bgcolor="#ffffff" style="text-align: left; vertical-align: top" valign="top"><a href="/twiki4/MAIN/bin/viewfile/TWiki/FileAttachment?rev=;filename=Sample.txt">Sample.txt</a></td>
125       <td align="left" bgcolor="#ffffff" style="text-align: left; vertical-align: top" valign="top"><a href="/twiki4/MAIN/bin/attach/TWiki/FileAttachment?filename=Sample.txt&revInfo=1" rel="nofollow" title="change, update, previous revisions, move, delete...">manage</a></td>
126       <td align="right" bgcolor="#ffffff" style="text-align: right; vertical-align: top" valign="top"> 0.1 K </td>
127       <td align="left" bgcolor="#ffffff" style="text-align: left; vertical-align: top" valign="top"> 22 Jul 2000 - 19:37 </td>
128       <td align="left" bgcolor="#ffffff" style="text-align: left; vertical-align: top" valign="top"><a href="TWikiContributor">TWikiContributor</a></td>
129       <td align="left" bgcolor="#ffffff" style="text-align: left; vertical-align: top" valign="top"> Just a sample </td>
130     </tr>
131     <tr>
132       <td align="center" bgcolor="#ffffff" style="text-align: center; vertical-align: top" valign="top"><img align="top" alt="gif" border="0" height="16" src="http://www.dementia.org/twiki//view/%SYSTEMWEB%/TWikiDocGraphics/gif.gif" width="16" /><span>gif</span></td>
133       <td align="left" bgcolor="#ffffff" style="text-align: left; vertical-align: top" valign="top"><a href="/twiki4/MAIN/bin/viewfile/TWiki/FileAttachment?rev=;filename=Smile.gif">Smile.gif</a></td>
134       <td align="left" bgcolor="#ffffff" style="text-align: left; vertical-align: top" valign="top"><a href="/twiki4/MAIN/bin/attach/TWiki/FileAttachment?filename=Smile.gif&revInfo=1" rel="nofollow" title="change, update, previous revisions, move, delete...">manage</a></td>
135       <td align="right" bgcolor="#ffffff" style="text-align: right; vertical-align: top" valign="top"> 0.1 K </td>
136       <td align="left" bgcolor="#ffffff" style="text-align: left; vertical-align: top" valign="top"> 22 Jul 2000 - 19:38 </td>
137       <td align="left" bgcolor="#ffffff" style="text-align: left; vertical-align: top" valign="top"><a href="TWikiContributor">TWikiContributor</a></td>
138       <td align="left" bgcolor="#ffffff" style="text-align: left; vertical-align: top" valign="top"> Smiley face </td>
139     </tr>
140   </table>
141 </div>
142
143 ## <a name="File Attachment Controls"></a> File Attachment Controls
144
145 Clicking on a <code>**Manage**</code> link takes you to a new page that looks a bit like this (depending on what [[skin|Main/TWikiSkins]] is selected):
146
147 <div>
148   <div>
149     <h3><a name="Attach new file"></a><a name=" Attach new file"></a> <a name="Attach_new_file"></a> Attach new file </h3>
150     <p> Select a new local file to update attachment <code>Sample.txt</code> <span>(<a href="#">UploadingUser</a>)</span><br />Upload up to 10000 KB. </p>
151     <p>
152     </p><input name="filepath" size="30" type="file" value="Sample.txt" /><input name="filename" type="hidden" value="Sample.txt" /></div>
153   <div>
154     <h3><a name="Comment"></a><a name=" Comment"></a> <a name="Comment"></a> Comment </h3>
155     <p> Describe the file so other people know what it is. </p>
156     <p>
157     </p><input maxlength="256" name="filecomment" size="50" type="text" value="Just a sample" /></div>
158   <div>
159     <h3><a name="Properties"></a><a name=" Properties"></a> <a name="Properties"></a> Properties </h3>
160     <p>
161     </p><input id="createlink" name="createlink" type="checkbox" /><label for="createlink">Create a link to the attached file</label><span>Images will be displayed, for other attachments a link will be created.</span><p>
162     </p><input id="hidefile" name="hidefile" type="checkbox" /><label for="hidefile">Do not show attachment in table</label><span>Attachments will not be shown in topic view page.</span></div>
163   <div><input name="changeproperties" type="submit" value="Change comment and properties only" /></div>
164 </div>
165
166 <a name="topic-actions"> </a>
167
168 <div>
169   <div style="margin-top: -1px"><span> <input type="submit" value="Upload file" /> or <a accesskey="c" href="#" rel="nofollow" title="Back to topic"><span class="twikiAccessKey">C</span>ancel</a></span></div>
170 </div>
171
172 - The first table is a list of all attachments, including their attributes. An `h` means the attachment is hidden, it isn't listed when viewing a topic.
173
174 - The second table is all the versions of the attachment. Click on **View** to see that version. If it's the most recent version, you'll be taken to an URL that always displays the latest version, which is usually what you want.
175   - **To change the comment** on an attachment, enter a new comment and then click **Change properties**. Note that the comment listed against the specific version will not change, however the comment displayed when viewing the topic does change.
176   - **To hide/unhide** an attachment, enable the <code>**Hide file**</code> checkbox, then click <code>**Change properties**</code>.
177
178 ## <a name="Known Issues"></a> Known Issues
179
180 - Unlike topics, attachments are not locked during editing. As a workaround, you can change the comment to indicate an attachment file is being worked on - the comment on the specific version isn't lost, it's there when you list all versions of the attachment.
181 - Attachments are not secured. Anyone can read them if they know the name of the web, topic and attachment.
182
183 **_Related Topics:_** [[UserDocumentationCategory]]