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%">
Comments
</textarea>
<input type="hidden" name="filename" value="%FILENAME%" />
<input type="file" name="filepath" value="%FILEPATH%" size="50" />
Comment:
<input type="text" name="filecomment" value="%FILECOMMENT%" maxlength="256" size="50" />
Link:
<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=" Upload file " />
</form>
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