admin_tool3Add my vote for this tag attachments4Add my vote for this tag automation3Add my vote for this tag import4Add my vote for this tag shell2Add my vote for this tag web_application2Add my vote for this tag create new tag
, view all tags

Upload to TWiki Add-On

Script to programmatically attach a file to any TWiki topic


This is a small Perl script to programmatically attach a file to any TWiki topic. The script can be executed on any computer, it does not have to be on the server where TWiki is installed. This script i useful to create mashups of TWiki and other applications.

The script is typically called from another script. As an actual use case, this script was used to attach audio voice files from voice mails to project pages in a TWiki application.


To attach a file to a TWiki topic, type this on the command line:

./uploadtotwiki.pl -l <login> -c <comment> <file(s)> <TWiki URL>
and enter the password when prompted.

Supported command line parameters:

  • -l login      - login name of TWiki account (optional)
  • -p password   - password of TWiki account (optional)
  • -c 'comment'  - comment of attached file (default: 'Uploaded by uploadtotwiki/2011-01-12')
  • -h 1          - hide attachment, 0 or 1 (default: 0)
  • -i 1          - inline attachment, e.g create link in topic text (default: 0)
  • -d 60         - delay in seconds between uploads of multiple files (default: 15)
  • file(s)       - one or more local files to upload (required)
  • URL           - view URL of TWiki topic, http or https protocol (required, must be last)


% ./uploadtotwiki.pl -l guest ./smile.gif http://twiki.org/cgi-bin/view/Sandbox/UploadTest
Uploading ./smile.gif to http://twiki.org/cgi-bin/view/Sandbox/UploadTest
Enter password for guest at twiki.org:
... upload finished.

Add-On Installation Instructions

Note: This is a command line tool for administrators; regular TWiki user can ignore this.

  • Download the ZIP file from the Add-on Home (see below)
  • Unzip UploadToTWikiAddOn.zip in your twiki installation directory. Content:
    File: Description:
    data/TWiki/UploadToTWikiAddOn.txt Add-on topic
    tools/uploadtotwiki.pl Add-on script
  • If inclined, move uploadtotwiki.pl to a different location or server
  • Run above example to test if the installation was successful
  • Install CPAN:LWP if missing (see CPAN instructions)


  • At this time the script only supports ApacheLogin only; support for TemplateLogin is pending.
  • Upload of files fail silently (without error message) if:
    • the file name has unsupported characters ($, @, ^, space, etc). Workaround: Rename files before upload.
    • the CSRF protection flag is set in configure. Workaround: Disable {CryptToken}{Enable} configure setting.
    • the user has no permission to update the topic.

Add-On Info

  • Set SHORTDESCRIPTION = Script to programmatically attach a file to any TWiki topic

Add-on Author: TWiki:Main.PeterThoeny
Copyright: © 2007-2012, Peter Thoeny, TWiki.org,
© 2007-2012 TWiki:TWiki.TWikiContributor
License: GPL (GNU General Public License)
Add-on Version: uploadtotwiki/2015-05-29
Change History:  
2015-05-29: TWikibug:Item7604: Switch from GPL v2 to v3
2012-11-24: TWikibug:Item6961: Doc improvements
2011-07-10: TWikibug:Item6725: Adding build stuff
2011-01-12: TWikibug:Item6530: Doc improvements
2007-02-12: Added -l, -p, -c, -h, -i, -d parameters; support for multiple files
2007-02-11: Initial version
TWiki Dependency: $TWiki::Plugins::VERSION 1.1 (TWiki 4.0)
CPAN Dependencies: LWP
Other Dependencies: none
Perl Version: 5.005
Add-on Home: http://TWiki.org/cgi-bin/view/Plugins/UploadToTWikiAddOn
Feedback: http://TWiki.org/cgi-bin/view/Plugins/UploadToTWikiAddOnDev
Appraisal: http://TWiki.org/cgi-bin/view/Plugins/UploadToTWikiAddOnAppraisal

Related Topic: TWikiAddOns

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatmd5 UploadToTWikiAddOn.md5 r8 r7 r6 r5 r4 manage 0.2 K 2015-05-29 - 21:08 PeterThoeny  
Compressed Zip archivetgz UploadToTWikiAddOn.tgz r8 r7 r6 r5 r4 manage 5.2 K 2015-05-29 - 21:07 PeterThoeny  
Compressed Zip archivezip UploadToTWikiAddOn.zip r8 r7 r6 r5 r4 manage 6.6 K 2015-05-29 - 21:07 PeterThoeny  
Unknown file formatEXT UploadToTWikiAddOn_installer r3 r2 r1 manage 3.5 K 2015-05-29 - 21:07 PeterThoeny  
Edit | Attach | Watch | Print version | History: r11 < r10 < r9 < r8 < r7 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r11 - 2015-05-29 - 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-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.