attachments5Remove my vote on this tag create new tag
, view all tags
ALERT! NOTE: This is a DistributionDocument. Please help maintain high quality documentation: This is a wiki, please fix the documentation if you find errors or incomplete content. Put questions and suggestions concerning the documentation of this topic in the comments section below. Use the Support web for problems you are having using TWiki.

File Attachments

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.

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 specific TWiki topics; collaborate on documents with full revision control; distribute documents on a 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.
    • 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% = HELP.

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 File Attachment table.
    • 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.
    • TWiki is capable of getting up to 10 files per upload session. Whether you can actually upload multiple files in one go from web user interface depends on skin.
    • 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.
    • 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.
    • TWiki can limit the file size. This is defined by the %ATTACHFILESIZELIMIT% variable of the TWikiPreferences, currently set at 5000 KB.
      • ALERT! 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.
  • Automatic attachments:
    • 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.
    • To enable this feature, set the {AutoAttachPubFiles} configuration option.
    • NOTE: The automatic attachment feature can only be used by an administrator who has access to the server's file system.

Downloading Files

  • ALERT! 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 for each.

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 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 file: Sample.txt
    2. Edit topic and enter: %ATTACHURL%/Sample.txt
    3. Preview: %ATTACHURL%/Sample.txt text appears as: /p/pub/TWiki/FileAttachment/Sample.txt, a link to the text file.

  • To reference an attachment located in another topic, enter:
    • %PUBURLPATH%/%WEB%/OtherTopic/Sample.txt (if it's within the same web)
    • %PUBURLPATH%/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
    2. Edit topic and write text: %INCLUDE{"%ATTACHURL%/Sample.txt"}%
      • Content of attached file is shown inlined.
      • Read more about INCLUDE in TWikiVariables

  • GIF, JPG and PNG images can be attached and shown embedded in a topic. Example:
    1. Attach file: Smile.gif
    2. Edit topic and write text: %ATTACHURL%/Smile.gif
    3. Preview: text appears as /p/pub/TWiki/FileAttachment/Smile.gif, an image.

File Attachment Contents Table

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.

Topic attachments
I Attachment History Action Size Date Who Comment
Texttxt Sample.txt   manage 0.1 K 2000-07-22 - 19:37 TWikiContributor Just a sample
GIFgif Smile.gif   manage 0.1 K 2000-07-22 - 19:38 TWikiContributor Smiley face

File Attachment Controls

Clicking on a Manage link takes you to a new page that looks a bit like this (depending on what skin is selected):

Attach new file

Select a new local file to update attachment Sample.txt (UploadingUser)
Upload up to 10000 KB.


Describe the file so other people know what it is.


Images will be displayed, for other attachments a link will be created.

Attachments will not be shown in topic view page.

or Cancel

  • 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.

  • 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.
    • 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.
    • To hide/unhide an attachment, enable the Hide file checkbox, then click Change properties.

File names

File systems tend to be liberal about characters used in file names. But there are characters which may cause problems if they are used in a file name of a TWiki attachment. As such, when TWiki saves an uploaded file attachment, it's saved as a file whose name is cleansed to avoid problems. Specifically:

  • Space are replaed by underscores
  • The .txt extension is appended to some filenames for security reasons
  • Characters such as ~, $, @, % are removed
  • Non-ASCII characters are deleted
When an attachment file name is altered by the process above, you are notified

Known Issues

  • 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.
  • Attachments are not secured by default. Anyone can read them if they know the name of the web, topic and attachment. Ask your TWiki administrator if TWiki is configured to secure attachments.

Related Topics: UserDocumentationCategory, TWikiAccessControl

Comments & Questions about this Distribution Document Topic

It would be nice to have some information about where on the filesystem attachments are stored, and whether the attachments location can be configured or redirected. Also, the section on deleting should include notes on how to manually delete a file from the filesystem after moving it to the Trash area. If these questions are covered in a separate topic, a link to that topic from here would be helpful. Thanks.

-- WesleySheldahl - 31 Jul 2002

You can see attachments are located if you look at the source; basically it's under the pub directory:


-- RichardLewis - 07 Oct 2002

Question: How do you "rename" a file attachment ? I have a case where I used TWikiDraw to create a nice diagram and I realized I drew the diagram for something else I was going to draw. Now the file attachment filename is basically wrong. How do I "rename" this file attachment AND keep all of its version history available ? This possible ?

I started the diagram using this in my TWiki page:


The file attachment created by TWikiDraw for this diagram is NFSDRIdea.draw (and the result gif if NFSDRIdea.gif). I want to change this to something else.

-- SeanONeill - 15 Nov 2002

Well, I renamed it by going to command line and changing the sources where this drawing was referenced including the ,v files. That seemed to work fine. I hoping there is an easier way.

-- SeanONeill - 19 Nov 2002

HELP Question: How do you disable revision control for binary attachments or even all attachments?

-- PeterSchmitt - 14 Jan 2004

Question: I need some help with an attachment problem... where is the best place to get it?

-- AsimKhan - 08 Oct 2004

As indicated on top, please use the Support web for questions. And also, as indicated below, please do not attach files here, use the Sandbox web.

-- PeterThoeny - 08 Oct 2004

I found the ATTACHLINKBOX = checked variable in the documentation (to change the default behaviour when I attach files). Question: What is the variable (if any) to set the default to Hide attachment in normal topic view?

-- NadimGhaznavi - 05 Dec 2005

You can set the ATTACHLINKBOX default in your TWiki.TWikiPreferences. There is no way to toggle all attachments on/off in the current production release.

-- PeterThoeny - 19 Dec 2005

Is there any work to make attachments secure? I noticed that if you can guess the name of the link you can download the attachement. Will there be a /bin/viewAttachment that will honor access control?

-- EricHanson - 06 Apr 2006

This is a current limitation. Please ask support questions in the Support web. Search that web for some hints.

-- PeterThoeny - 06 Apr 2006

a viewfile is supplied in DakarRelease to support proper security for attachments. if you're still seeing documents in the pub directly using a URL, you should update your .htaccess file

-- WillNorris - 07 Apr 2006

The viewfile script already existed prior to Dakar. The Dakar version delivers always via script; the Cairo version redirected to pub for top revision. There is a compatibility and performance issue if all files in pub are no longer accessible via pub, such as image files. For example, %ATTACHURL%/TWiki/TWikiDocGraphics/viewtopic.gif no longer works. The secure setup for attachments should be documented in SecuringYourTWiki#Securing_attachments.

-- PeterThoeny - 06 Apr 2006

I'm having trouble moving attachments to a topic that's not a WikiWord. I see the error Please go back in your browser and chose a topic name that is a WikiWord or check the allow non-Wiki Word box but I cannot find that option anywhere. Help please?

-- TobyThain - 25 May 2006

This is a bug. Please do not report bugs here. I filed Bugs:Item2349.

-- PeterThoeny - 25 May 2006

This page contains no information on version control of attachments. We need clarification on intended functionality when uploaded filename and managed filename don't match. Bugs:Item1817

-- JadeCravy - 12 Jul 2006

Is the notification funtion could notify the updating of attachment?

-- ArdenSun - 22 Aug 2006

Please ask support questions in the Support web. (Updating attachments induces a topic save; notification is done when a topic is saved, unless the do not notify flag is set.)

-- PeterThoeny - 22 Aug 2006

I would like to see a 'white list' of extensions as an option to use in place of the UploadFilter config variable. This would allow a site to specify exactly which extensions were allowed. All other filenames and filenames with more than one dot could be rejected with a 'this file type is not allowed' type of message. I envision that if the 'ok list' is populated UploadFilter would not be used but if the 'ok list' is empty UploadFilter would work as it does now. This allows a way to have the specific list while keeping the current functionality unchanged.

-- DavidAldrich - 12 Sep 2006

Thanks for the feedback. This section is for feedback on the documentation of this topic. Please bring this forward as a feature request in the Codev web.

-- PeterThoeny - 13 Sep 2006

Hi, I am having a problem attaching the files.After attaching I am not able to delete the file.An error occurs:---+ Attention Attachment move failed During move of attachment logo.gif% to . an error was found. Please notify your administrator.

Attachment does not exist

Please go back in your browser and try again.

Why does it happen though the file is present

-- TWikiGuest - 29 Oct 2006

Please ask support questions in the Support web; this section here is about the documentation of file attachments. Also, please register with a real name (not just B for last name.)

-- PeterThoeny - 29 Oct 2006

Is it be possible to provide drag&drop functionality for adding attachments to a topic?

-- BerndSGoetz - 27 Mar 2007

I will bring the drag&drop feature request in the code development web.

-- BerndSGoetz - 27 Mar 2007

How is Revision control done in Twiki. Meaning, if I have 2 versions of a docment, are the 2 versions stored separately in the server. If so, in which location. I am asking this because I am concerned about the space occupied in the server if the 2 versions are stored separately. If not, how are the versions distinguished?

-- AnithaMadhan - 10 May 2007

The latest version of an attachment is stored as is, but for previous version only the difference between file versions is stored.

-- PeterThoeny - 10 May 2007

Well, that's not exactly true, cause RCS is not able to do binary merges so the ,v files gets larger and larger (cause it includes all older versions) and should be deleted from time to time for large binary attachments.

-- FranzJosefSilli - 11 May 2007

Indeed, you are right. RCS uses the GNU diff which only report that binary files differ, not an actual diff.

-- PeterThoeny - 12 May 2007

How do you have a audit on the documents when they are downloaded by the users...?

-- AsithaGoonewardena - 08 Jun 2007

Please ask support questions in the Support web, thanks.

-- PeterThoeny - 08 Jun 2007

The use of Automatic attachments is unclear in the doc (what to add to which config file) and what the user will view in a topic where attachements have been bulk-added. Is it compatible with the IMAGEGALLERY plugin?

-- ChristopheMertz - 12 Nov 2007

It is documented in the screen of the configure script. Good point, the doc is missing in this topic. Please feel free to enhance the docs when you find out.

I do not know if it is compatible with the ImageGalleryPlugin. You can ask in the plugin's Dev topic.

-- PeterThoeny - 13 Nov 2007

In my Twiki environoment; I can't display the attach file. It seems the Twiki does not understand the attach files.

-- JingKunZhau - 10 Jul 2008

I use Linux Redhat.

-- JingKunZhau - 10 Jul 2008

Please as support questions in the Support web.

-- PeterThoeny - 13 Jul 2008

is there any way to delete numerous attachements at once in like a batch? Oppossed to deleting each attachement through manage, delete, trash?

-- ChristeneFossella - 2011-01-06

This is not possible yet, a bulk feature for attachments would be a useful enhancement.

If you are the admin and have shell access you can cheat the system:

  • Edit and save the topic (so that you are recorded as the person making a change (for accountability)).
  • Do a cmd=repRev edit on the topic (you need to be an admin). You will see all meta data.
  • Delete the meta data of all file you want to delete, the save the topic
  • On shell, go to twiki/pub/Myweb/MyTopic/ and delete the files you want to delete (make sure the meta data and files are in synch)

-- PeterThoeny - 2011-01-06

Please use the Support forum if you have questions about TWiki features. This comment section is about the documentation of this topic.

NOTE: Please use the Sandbox web to test the file attachment feature
Topic attachments
I Attachment History Action Size Date Who Comment
Texttxt Sample.txt r1 manage 0.1 K 2007-04-13 - 02:39 PaulWise test
GIFgif Smile.gif   manage 0.1 K 1999-06-08 - 05:52 UnknownUser Smiley face
Edit | Attach | Watch | Print version | History: r79 < r78 < r77 < r76 < r75 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r79 - 2014-12-16 - PeterThoeny
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2015 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.