create new tag
, view all tags
As of now, submitting attachments is a two-step process: You first take user to "edit" page (with required template contents) and then followed by attach. Non-intutive for many users who simply want to submit documents and leave the organization of information to other people.

I instead propose a single form that will allow:

  • Attachments
  • Form Data
  • usual "text" part, which, if it exists, will be treated like comments.

So I modified 'TWiki::UI::Upload::upload()' to include this small code:

  use TWiki::UI::Save;
  # Before first call to updateAttachment() in upload() function; like 435 or so. (Latest beta).
  # Create topic if it doesn't exist; possibly using template
  if ( $query->param('createtopic') && ! TWiki::Store::topicExists( $webName, $topic ) ) {
     if ( !TWiki::UI::Save::save( $webName, $topic, $userName, $query, 1) ) { # Subroutine call, shouldn't redirect.
            TWiki::writeDebug("create topic failed.");

And the form should look like this: (I have added variable 'createtopic').

<form name="main" enctype="multipart/form-data" action="%SCRIPTURLPATH%/upload%SCRIPTSUFFIX%/%WEB%/%TOPIC%" method="post">
   <input type="hidden" name="createtopic" value="1" />
   <textarea name="text" wrap="virtual" rows="15" cols="70" style="width: 99%">

   <input type="hidden" name="filename" value="%FILENAME%" />
   <input type="file" name="filepath" value="%FILEPATH%" size="50" />
      <input type="text" name="filecomment" value="%FILECOMMENT%" maxlength="256" size="50" />
     <input type="checkbox" name="createlink" %ATTACHLINKBOX% /> Create a link to the attached file at the end of the topic.
   Hide file:
      <input type="checkbox" name="hidefile" %HIDEFILE% /> Hide attachment in normal topic view.

   Submit Button:
   <input type="submit" value=" &nbsp; Upload file &nbsp; " />

Seems to work (didn't try to break it though.) Should I take anything else into consideration?

And, is it the right approach? Should we have a uniform script combining both attach and save? (and preview etc.)

-- VinodKulkarni - 07 Jul 2004

Does this solve HowToAutoAttachImageOnTopicCreation?

-- FranzJosefGigler - 28 May 2008

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r2 - 2008-05-28 - FranzJosefGigler
  • 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.